From fb45ed86527a89ef4f012cbdbf2e542bba1cad7f Mon Sep 17 00:00:00 2001 From: cubemaze Date: Sun, 6 Aug 2023 13:02:34 +0800 Subject: [PATCH 1/2] fix: shadowsocks --- core/sing/node.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/core/sing/node.go b/core/sing/node.go index e43bf7c..5b9efb5 100644 --- a/core/sing/node.go +++ b/core/sing/node.go @@ -99,22 +99,29 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio } case "shadowsocks": in.Type = "shadowsocks" - p := make([]byte, 32) - _, _ = rand.Read(p) - randomPasswd := hex.EncodeToString(p) - if strings.Contains(info.Cipher, "2022") { - randomPasswd = base64.StdEncoding.EncodeToString([]byte(randomPasswd)) + var keyLength int + switch info.Cipher { + case "2022-blake3-aes-128-gcm": + keyLength = 16 + case "2022-blake3-aes-256-gcm": + keyLength = 32 + default: + keyLength = 8 } in.ShadowsocksOptions = option.ShadowsocksInboundOptions{ ListenOptions: listen, Method: info.Cipher, - Password: info.ServerKey, - Users: []option.ShadowsocksUser{ - { - Password: randomPasswd, - }, - }, } + p := make([]byte, keyLength) + _, _ = rand.Read(p) + randomPasswd := hex.EncodeToString(p) + if strings.Contains(info.Cipher, "2022") { + randomPasswd = base64.StdEncoding.EncodeToString([]byte(randomPasswd)) + in.ShadowsocksOptions.Password = randomPasswd + } + in.ShadowsocksOptions.Users = []option.ShadowsocksUser{{ + Password: randomPasswd, + }} } return in, nil } From 100de12c21fade142359524b97e819fd0a93eb1e Mon Sep 17 00:00:00 2001 From: cubemaze Date: Sun, 6 Aug 2023 15:34:12 +0800 Subject: [PATCH 2/2] fix: bug --- core/sing/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sing/user.go b/core/sing/user.go index cfab779..a90707d 100644 --- a/core/sing/user.go +++ b/core/sing/user.go @@ -49,7 +49,7 @@ func (b *Box) AddUsers(p *core.AddUsersParams) (added int, err error) { } func (b *Box) GetUserTraffic(tag, uuid string, reset bool) (up int64, down int64) { - if v, ok := b.hookServer.Hooker().counter.Load(tag); ok { + if v, ok := b.hookServer.counter.Load(tag); ok { c := v.(*counter.TrafficCounter) up = c.GetUpCount(uuid) down = c.GetDownCount(uuid)