feat(shadowsocks): SIP022 AEAD-2022 Ciphers

This commit is contained in:
Chang lue Tsen
2025-05-31 10:46:28 -04:00
parent ddf740600f
commit 1a21984c27
3 changed files with 43 additions and 2 deletions
@@ -86,6 +86,26 @@ func (l *UpdateNodeLogic) UpdateNode(req *types.UpdateNodeRequest) error {
}
config, _ = json.Marshal(cfg)
nodeInfo.Config = string(config)
} else if req.Protocol == "shadowsocks" {
var cfg types.Shadowsocks
if err = json.Unmarshal(config, &cfg); err != nil {
l.Errorf("[CreateNode] Unmarshal Shadowsocks Config Error: %v", err.Error())
return errors.Wrapf(xerr.NewErrCode(xerr.ERROR), "json.Unmarshal error: %v", err.Error())
}
if strings.Contains(cfg.Method, "2022") {
var length int
switch cfg.Method {
case "2022-blake3-aes-128-gcm":
length = 16
default:
length = 32
}
if len(cfg.ServerKey) != length {
cfg.ServerKey = tool.GenerateCipher(cfg.ServerKey, length)
}
}
config, _ = json.Marshal(cfg)
nodeInfo.Config = string(config)
}
err = l.svcCtx.ServerModel.Update(l.ctx, nodeInfo)
if err != nil {