DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go): - GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面 - GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新 - 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新) - 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍 - 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0) - 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算 启动器(Python/JS): - 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭 - GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐) - 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
This commit is contained in:
commit
645b64fe21
4388 files changed
+1405457
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package replay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrReplayKeyRequired 通过 errors.Is 暴露空 nonce key。
|
||||
ErrReplayKeyRequired = errors.New("replay: key is required")
|
||||
// ErrReplayTTLRequired 通过 errors.Is 暴露非法 replay 保留窗口。
|
||||
ErrReplayTTLRequired = errors.New("replay: ttl must be positive")
|
||||
// ErrReplayStoreUnavailable 通过 errors.Is 暴露 nil 或不可用 store。
|
||||
ErrReplayStoreUnavailable = errors.New("replay: store is unavailable")
|
||||
// ErrReplayStoreFull 表示不能通过驱逐未过期 nonce 来接收新 nonce。
|
||||
ErrReplayStoreFull = errors.New("replay: store is full")
|
||||
)
|
||||
|
||||
// Store 记录短生命周期 nonce 是否已经出现过;实现必须保证 check+write 原子化。
|
||||
type Store interface {
|
||||
// Seen 在 key 首次出现时返回 (true, nil),重复出现时返回 (false, nil)。
|
||||
// ttl 是最大保留窗口,应略大于调用方的 MaxSkew。
|
||||
Seen(ctx context.Context, key string, ttl time.Duration) (firstSeen bool, err error)
|
||||
}
|
||||
|
||||
func normalizeInput(ctx context.Context, key string, ttl time.Duration) (context.Context, string, error) {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
key = strings.TrimSpace(key)
|
||||
if key == "" {
|
||||
return nil, "", ErrReplayKeyRequired
|
||||
}
|
||||
if ttl <= 0 {
|
||||
return nil, "", ErrReplayTTLRequired
|
||||
}
|
||||
return ctx, key, nil
|
||||
}
|
||||
|
||||
func wrapRedisError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("%w: %w", ErrReplayRedisOperationFailed, err)
|
||||
}
|
||||
Reference in new issue
Block a user