chore: simplify server config and add keygen for sudoku (#2407)

This commit is contained in:
futai
2025-12-01 19:26:41 +08:00
committed by GitHub
parent a001b1b110
commit 9a5e506f66
5 changed files with 17 additions and 11 deletions

View File

@@ -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))
}
}

View File

@@ -1587,7 +1587,6 @@ listeners:
aead-method: chacha20-poly1305 # 支持chacha20-poly1305或者aes-128-gcm以及nonesudoku的混淆层可以确保none情况下数据安全
padding-min: 1 # 填充最小长度
padding-max: 15 # 填充最大长度,均不建议过大
seed: "<seed-or-key>" # 如果你不使用ED25519密钥对就请填入uuid否则仍然是公钥
table-type: prefer_ascii # 可选值prefer_ascii、prefer_entropy 前者全ascii映射后者保证熵值汉明1低于3
handshake-timeout: 5 # optional

View File

@@ -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"`
}

View File

@@ -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 {

View File

@@ -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