chore: add customized byte style for sudoku (#2427)

This commit is contained in:
saba-futai
2025-12-10 17:47:59 +08:00
committed by GitHub
parent e652e277a7
commit 2211789a7c
10 changed files with 80 additions and 11 deletions

View File

@@ -30,6 +30,7 @@ type SudokuOption struct {
TableType string `proxy:"table-type,omitempty"` // "prefer_ascii" or "prefer_entropy"
EnablePureDownlink *bool `proxy:"enable-pure-downlink,omitempty"`
HTTPMask bool `proxy:"http-mask,omitempty"`
CustomTable string `proxy:"custom-table,omitempty"` // optional custom byte layout, e.g. xpxvvpvv
}
// DialContext implements C.ProxyAdapter
@@ -178,13 +179,17 @@ func NewSudoku(option SudokuOption) (*Sudoku, error) {
ServerAddress: net.JoinHostPort(option.Server, strconv.Itoa(option.Port)),
Key: option.Key,
AEADMethod: defaultConf.AEADMethod,
Table: sudoku.NewTable(sudoku.ClientAEADSeed(option.Key), tableType),
PaddingMin: paddingMin,
PaddingMax: paddingMax,
EnablePureDownlink: enablePureDownlink,
HandshakeTimeoutSeconds: defaultConf.HandshakeTimeoutSeconds,
DisableHTTPMask: !option.HTTPMask,
}
table, err := sudoku.NewTableWithCustom(sudoku.ClientAEADSeed(option.Key), tableType, option.CustomTable)
if err != nil {
return nil, fmt.Errorf("build table failed: %w", err)
}
baseConf.Table = table
if option.AEADMethod != "" {
baseConf.AEADMethod = option.AEADMethod
}