From 07acba96bff8330c4e34321a27c7b78bf37786f2 Mon Sep 17 00:00:00 2001 From: cubemaze Date: Mon, 7 Aug 2023 09:50:48 +0800 Subject: [PATCH] fix: shadowsocks --- core/sing/node.go | 2 +- core/sing/user.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/sing/node.go b/core/sing/node.go index 5b9efb5..2a64f42 100644 --- a/core/sing/node.go +++ b/core/sing/node.go @@ -116,8 +116,8 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio _, _ = rand.Read(p) randomPasswd := hex.EncodeToString(p) if strings.Contains(info.Cipher, "2022") { + in.ShadowsocksOptions.Password = info.ServerKey randomPasswd = base64.StdEncoding.EncodeToString([]byte(randomPasswd)) - in.ShadowsocksOptions.Password = randomPasswd } in.ShadowsocksOptions.Users = []option.ShadowsocksUser{{ Password: randomPasswd, diff --git a/core/sing/user.go b/core/sing/user.go index a72755f..775f720 100644 --- a/core/sing/user.go +++ b/core/sing/user.go @@ -1,6 +1,7 @@ package sing import ( + "encoding/base64" "errors" "github.com/InazumaV/V2bX/api/panel" @@ -36,9 +37,16 @@ func (b *Box) AddUsers(p *core.AddUsersParams) (added int, err error) { case "shadowsocks": us := make([]option.ShadowsocksUser, len(p.UserInfo)) for i := range p.UserInfo { + var password = p.UserInfo[i].Uuid + switch p.NodeInfo.Cipher { + case "2022-blake3-aes-128-gcm": + password = base64.StdEncoding.EncodeToString([]byte(password[:16])) + case "2022-blake3-aes-256-gcm": + password = base64.StdEncoding.EncodeToString([]byte(password[:32])) + } us[i] = option.ShadowsocksUser{ Name: p.UserInfo[i].Uuid, - Password: p.UserInfo[i].Uuid, + Password: password, } } err = b.inbounds[p.Tag].(*inbound.ShadowsocksMulti).AddUsers(us)