update: add ss plugin support ss2022

The error message will have more details
This commit is contained in:
Senis John 2022-12-16 20:43:38 +08:00
parent b09f371447
commit 0777cc8892
No known key found for this signature in database
GPG Key ID: 845E9E4727C3E1A4
2 changed files with 19 additions and 7 deletions

View File

@ -217,7 +217,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
if c.SpeedLimit > 0 {
u.SpeedLimit = uint64(c.SpeedLimit * 1000000 / 8)
} else {
u.SpeedLimit = uint64(user.Get("speed_limit").MustUint64() * 1000000 / 8)
u.SpeedLimit = user.Get("speed_limit").MustUint64() * 1000000 / 8
}
u.DeviceLimit = c.DeviceLimit // todo waiting v2board send configuration

View File

@ -78,18 +78,18 @@ func (c *Controller) buildSSUser(userInfo *[]api.UserInfo, method string) (users
users = make([]*protocol.User, len(*userInfo))
for i, user := range *userInfo {
// // 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)) {
e := c.buildUserTag(&user)
if len(user.Passwd) < 16 {
newError("shadowsocks2022 key's length must be greater than 16").AtError().WriteToLog()
return
newError(fmt.Errorf("[UID: %d] shadowsocks2022 key's length must be greater than 16", user.UID)).AtError().WriteToLog()
continue
}
userKey := user.Passwd[:16]
if strings.Contains(method, "256") {
if len(user.Passwd) < 32 {
newError("shadowsocks2022 key's length must be greater than 32").AtError().WriteToLog()
return
newError(fmt.Errorf("[UID: %d] shadowsocks2022 key's length must be greater than 32", user.UID)).AtError().WriteToLog()
continue
}
userKey = user.Passwd[:32]
}
@ -123,11 +123,23 @@ func (c *Controller) buildSSPluginUser(userInfo *[]api.UserInfo) (users []*proto
// shadowsocks2022 Key = openssl rand -base64 32 and multi users needn't cipher method
if C.Contains(shadowaead_2022.List, strings.ToLower(user.Method)) {
e := c.buildUserTag(&user)
if len(user.Passwd) < 16 {
newError(fmt.Errorf("[UID: %d] shadowsocks2022 key's length must be greater than 16", user.UID)).AtError().WriteToLog()
continue
}
userKey := user.Passwd[:16]
if strings.Contains(user.Method, "256") {
if len(user.Passwd) < 32 {
newError(fmt.Errorf("[UID: %d] shadowsocks2022 key's length must be greater than 32", user.UID)).AtError().WriteToLog()
continue
}
userKey = user.Passwd[:32]
}
users[i] = &protocol.User{
Level: 0,
Email: e,
Account: serial.ToTypedMessage(&shadowsocks_2022.User{
Key: base64.StdEncoding.EncodeToString([]byte(user.Passwd)),
Key: base64.StdEncoding.EncodeToString([]byte(userKey)),
Email: e,
Level: 0,
}),