fix: Priority local speed limit

This commit is contained in:
Senis John 2022-12-15 19:48:13 +08:00
parent addde0f8d4
commit 040e19ee87
No known key found for this signature in database
GPG Key ID: 845E9E4727C3E1A4
2 changed files with 14 additions and 6 deletions

View File

@ -208,11 +208,19 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
userList := make([]api.UserInfo, numOfUsers) userList := make([]api.UserInfo, numOfUsers)
for i := 0; i < numOfUsers; i++ { for i := 0; i < numOfUsers; i++ {
user := response.Get("users").GetIndex(i) user := response.Get("users").GetIndex(i)
u := api.UserInfo{} u := api.UserInfo{
u.UID = user.Get("id").MustInt() UID: user.Get("id").MustInt(),
u.SpeedLimit = uint64(user.Get("speed_limit").MustInt() * 1000000 / 8) UUID: user.Get("uuid").MustString(),
}
// Support 1.7.1 speed limit
if c.SpeedLimit > 0 {
u.SpeedLimit = uint64(c.SpeedLimit * 1000000 / 8)
} else {
u.SpeedLimit = user.Get("speed_limit").MustUint64() * 1000000 / 8
}
u.DeviceLimit = c.DeviceLimit // todo waiting v2board send configuration u.DeviceLimit = c.DeviceLimit // todo waiting v2board send configuration
u.UUID = user.Get("uuid").MustString()
u.Email = u.UUID + "@v2board.user" u.Email = u.UUID + "@v2board.user"
if c.NodeType == "Shadowsocks" { if c.NodeType == "Shadowsocks" {
u.Passwd = u.UUID u.Passwd = u.UUID

View File

@ -592,7 +592,7 @@ func (c *APIClient) ParseSSUserListResponse(userInfoResponse *json.RawMessage) (
if c.SpeedLimit > 0 { if c.SpeedLimit > 0 {
speedlimit = uint64((c.SpeedLimit * 1000000) / 8) speedlimit = uint64((c.SpeedLimit * 1000000) / 8)
} else { } else {
speedlimit = uint64((user.SpeedLimit * 1000000) / 8) speedlimit = user.SpeedLimit * 1000000 / 8
} }
userList[i] = api.UserInfo{ userList[i] = api.UserInfo{
UID: user.UID, UID: user.UID,