From 9a5e506f66795c3d43c6795d74b00c0f3ad3954a Mon Sep 17 00:00:00 2001 From: futai <120904569+saba-futai@users.noreply.github.com> Date: Mon, 1 Dec 2025 19:26:41 +0800 Subject: [PATCH] chore: simplify server config and add keygen for sudoku (#2407) --- component/generator/cmd.go | 17 ++++++++++++++++- docs/config.yaml | 1 - listener/config/sudoku.go | 1 - listener/inbound/sudoku.go | 2 -- listener/sudoku/server.go | 7 +------ 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/component/generator/cmd.go b/component/generator/cmd.go index 320bb11d..39064c71 100644 --- a/component/generator/cmd.go +++ b/component/generator/cmd.go @@ -6,13 +6,14 @@ import ( "github.com/metacubex/mihomo/component/ech" "github.com/metacubex/mihomo/transport/vless/encryption" + "github.com/saba-futai/sudoku/pkg/crypto" "github.com/gofrs/uuid/v5" ) func Main(args []string) { if len(args) < 1 { - panic("Using: generate uuid/reality-keypair/wg-keypair/ech-keypair/vless-mlkem768/vless-x25519") + panic("Using: generate uuid/reality-keypair/wg-keypair/ech-keypair/vless-mlkem768/vless-x25519/sudoku-keypair") } switch args[0] { case "uuid": @@ -69,5 +70,19 @@ func Main(args []string) { fmt.Println("PrivateKey: " + privateKeyBase64) fmt.Println("Password: " + passwordBase64) fmt.Println("Hash32: " + hash32Base64) + case "sudoku-keypair": + // Generate Master Key + pair, err := crypto.GenerateMasterKey() + if err != nil { + panic(err) + } + // Split the master private key to get Available Private Key + availablePrivateKey, err := crypto.SplitPrivateKey(pair.Private) + if err != nil { + panic(err) + } + // Output: Available Private Key for client, Master Public Key for server + fmt.Println("PrivateKey: " + availablePrivateKey) + fmt.Println("PublicKey: " + crypto.EncodePoint(pair.Public)) } } diff --git a/docs/config.yaml b/docs/config.yaml index bef2c659..2f959f33 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -1587,7 +1587,6 @@ listeners: aead-method: chacha20-poly1305 # 支持chacha20-poly1305或者aes-128-gcm以及none,sudoku的混淆层可以确保none情况下数据安全 padding-min: 1 # 填充最小长度 padding-max: 15 # 填充最大长度,均不建议过大 - seed: "" # 如果你不使用ED25519密钥对,就请填入uuid,否则仍然是公钥 table-type: prefer_ascii # 可选值:prefer_ascii、prefer_entropy 前者全ascii映射,后者保证熵值(汉明1)低于3 handshake-timeout: 5 # optional diff --git a/listener/config/sudoku.go b/listener/config/sudoku.go index 855795f1..79aadf5d 100644 --- a/listener/config/sudoku.go +++ b/listener/config/sudoku.go @@ -11,7 +11,6 @@ type SudokuServer struct { AEADMethod string `json:"aead-method,omitempty"` PaddingMin *int `json:"padding-min,omitempty"` PaddingMax *int `json:"padding-max,omitempty"` - Seed string `json:"seed,omitempty"` TableType string `json:"table-type,omitempty"` HandshakeTimeoutSecond *int `json:"handshake-timeout,omitempty"` } diff --git a/listener/inbound/sudoku.go b/listener/inbound/sudoku.go index d6e84af3..bc08772a 100644 --- a/listener/inbound/sudoku.go +++ b/listener/inbound/sudoku.go @@ -19,7 +19,6 @@ type SudokuOption struct { AEADMethod string `inbound:"aead-method,omitempty"` PaddingMin *int `inbound:"padding-min,omitempty"` PaddingMax *int `inbound:"padding-max,omitempty"` - Seed string `inbound:"seed,omitempty"` TableType string `inbound:"table-type,omitempty"` // "prefer_ascii" or "prefer_entropy" HandshakeTimeoutSecond *int `inbound:"handshake-timeout,omitempty"` } @@ -53,7 +52,6 @@ func NewSudoku(options *SudokuOption) (*Sudoku, error) { AEADMethod: options.AEADMethod, PaddingMin: options.PaddingMin, PaddingMax: options.PaddingMax, - Seed: options.Seed, TableType: options.TableType, } if options.HandshakeTimeoutSecond != nil { diff --git a/listener/sudoku/server.go b/listener/sudoku/server.go index 87b2abd9..ce2b09af 100644 --- a/listener/sudoku/server.go +++ b/listener/sudoku/server.go @@ -71,17 +71,12 @@ func New(config LC.SudokuServer, tunnel C.Tunnel, additions ...inbound.Addition) return nil, err } - seed := config.Seed - if seed == "" { - seed = config.Key - } - tableType := strings.ToLower(config.TableType) if tableType == "" { tableType = "prefer_ascii" } - table := sudokuobfs.NewTable(seed, tableType) + table := sudokuobfs.NewTable(config.Key, tableType) defaultConf := apis.DefaultConfig() paddingMin := defaultConf.PaddingMin