Files
90CNServer/server/cmd/scratch/s2cvectors/main.go
T
hanfuit 645b64fe21 DNF90 服务端与启动器完整源码(含 GM 工具功能增强)
服务端(Go):
- GM 塞背包/带属性装备发放:在线角色推送 op14 增量物品行,背包实时刷新,无需回角色选择界面
- GM 改金币/改等级:去掉在线拒绝,落库后推送 op14 钱包/op37 等级状态,在线实时刷新
- 等级端点统一切换到新版 GMSetCharacterLevel(自带在线刷新)
- 无限/锁死疲劳模式 + 燃烧疲劳:每房间消耗 2 点、打怪与通关经验双倍
- 燃烧疲劳开关时给所有在线角色推送系统提示(op12 mode 0)
- 深渊史诗掉率:GM 全局倍率 + 城镇增益药剂窗口倍率,真实接入掉落结算

启动器(Python/JS):
- 标题栏自绘、窗口 1204x717、禁止拖拽改大小、仅最小化/关闭
- GM 工具:疲劳与燃烧、深渊史诗掉率、拍卖行上架(单一定价对齐)
- 拍卖行上架前端对齐服务端单一价格语义,修复 400 报错
2026-11-04 14:31:55 +08:00

73 lines
2.1 KiB
Go

// Command s2cvectors 打印 C 侧自检要用的固定向量(用完即留:它是跨实现契约的一部分)。
//
// 用法:go run ./cmd/scratch/s2cvectors
// 输出必须与 client-patch/s2ccrypt.c 内建向量、protocol/s2ccipher_test.go 的常量三者一致。
package main
import (
"encoding/hex"
"fmt"
dnfproto "longheng.io/server/internal/modules/dnf/protocol"
)
func main() {
key, err := dnfproto.ParseS2CMasterKey([]byte(dnfproto.DefaultS2CMasterKeyBase64))
if err != nil {
panic(err)
}
nonce, _ := hex.DecodeString("00112233445566778899aabbccddeeff")
fmt.Printf("master key : %s\n", dnfproto.DefaultS2CMasterKeyBase64)
fmt.Printf("master key hex : %s\n", hex.EncodeToString(key))
fmt.Printf("connection nonce: %s\n\n", hex.EncodeToString(nonce))
cases := []struct {
name string
msgID uint16
seq uint16
body []byte
}{
{"short op38 body", 38, 4242, mustHex("0b000000ff00cafe0102030405060708090a")},
{"multi-block 64B", 45, 777, sequential(64)},
{"block aligned 32B", 29, 1, sequential(32)},
{"one byte", 1, 65535, []byte{0x5a}},
{"2048 bytes", 1518, 2, sequential(2048)},
}
for _, testCase := range cases {
cipher, err := dnfproto.NewS2CCipher(key, nonce)
if err != nil {
panic(err)
}
sealed := append([]byte(nil), testCase.body...)
cipher.Apply(sealed, testCase.msgID, testCase.seq)
fmt.Printf("%-18s msgID=%-5d seq=%-5d len=%-5d\n", testCase.name, testCase.msgID, testCase.seq, len(testCase.body))
fmt.Printf(" plain : %s\n", printableOrHex(testCase.body))
fmt.Printf(" cipher : %s\n", printableOrHex(sealed))
}
}
func mustHex(text string) []byte {
raw, err := hex.DecodeString(text)
if err != nil {
panic(err)
}
return raw
}
func sequential(size int) []byte {
out := make([]byte, size)
for i := range out {
out[i] = byte(i)
}
return out
}
// 短向量直接给十六进制;超过 80 字节的只给前 64 字节(C 侧自检按同样规则比对)。
func printableOrHex(data []byte) string {
if len(data) <= 80 {
return hex.EncodeToString(data)
}
return fmt.Sprintf("first64=%s pattern=byte(i)", hex.EncodeToString(data[:64]))
}