fix: trim length of userKey for ss2022

This commit is contained in:
Senis John 2022-12-13 20:43:02 +08:00
parent eea6c0dea6
commit acd3cce667
No known key found for this signature in database
GPG Key ID: 845E9E4727C3E1A4

View File

@ -81,11 +81,15 @@ func (c *Controller) buildSSUser(userInfo *[]api.UserInfo, method string) (users
// // shadowsocks2022 Key = openssl rand -base64 32 and multi users needn't cipher method // // shadowsocks2022 Key = openssl rand -base64 32 and multi users needn't cipher method
if C.Contains(shadowaead_2022.List, strings.ToLower(method)) { if C.Contains(shadowaead_2022.List, strings.ToLower(method)) {
e := c.buildUserTag(&user) e := c.buildUserTag(&user)
userKey := user.Passwd[:32]
if strings.Contains(method, "128") {
userKey = userKey[:16]
}
users[i] = &protocol.User{ users[i] = &protocol.User{
Level: 0, Level: 0,
Email: e, Email: e,
Account: serial.ToTypedMessage(&shadowsocks_2022.User{ Account: serial.ToTypedMessage(&shadowsocks_2022.User{
Key: base64.StdEncoding.EncodeToString([]byte(user.Passwd)), Key: base64.StdEncoding.EncodeToString([]byte(userKey)),
Email: e, Email: e,
Level: 0, Level: 0,
}), }),