mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-02-02 06:48:14 -05:00
fix bug
This commit is contained in:
parent
c3995c79e9
commit
aa8ae319db
@ -51,7 +51,6 @@ type Client struct {
|
|||||||
access sync.Mutex
|
access sync.Mutex
|
||||||
NodeInfoRspMd5 [16]byte
|
NodeInfoRspMd5 [16]byte
|
||||||
NodeRuleRspMd5 [16]byte
|
NodeRuleRspMd5 [16]byte
|
||||||
UserListCheckNum int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(apiConfig *Config) API {
|
func New(apiConfig *Config) API {
|
||||||
|
10
api/user.go
10
api/user.go
@ -69,16 +69,6 @@ func (c *Client) GetUserList() (UserList *[]UserInfo, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unmarshal userlist error: %s", err)
|
return nil, fmt.Errorf("unmarshal userlist error: %s", err)
|
||||||
}
|
}
|
||||||
l := len(userList.Data)
|
|
||||||
checkNum := userList.Data[l-1].UID + userList.Data[l/2-1].UID +
|
|
||||||
userList.Data[l/3-1].UID + userList.Data[l/4-1].UID +
|
|
||||||
userList.Data[l/5-1].UID + userList.Data[0].UID
|
|
||||||
if c.UserListCheckNum != 0 {
|
|
||||||
if c.UserListCheckNum == checkNum {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.UserListCheckNum = checkNum
|
|
||||||
return &userList.Data, nil
|
return &userList.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,9 +190,7 @@ func (c *Controller) nodeInfoMonitor() (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if nodeInfoChanged {
|
if nodeInfoChanged {
|
||||||
if newUserInfo != nil {
|
|
||||||
c.userList = newUserInfo
|
c.userList = newUserInfo
|
||||||
}
|
|
||||||
newUserInfo = nil
|
newUserInfo = nil
|
||||||
err = c.addNewUser(c.userList, newNodeInfo)
|
err = c.addNewUser(c.userList, newNodeInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -206,7 +204,7 @@ func (c *Controller) nodeInfoMonitor() (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
} else if newUserInfo != nil {
|
} else {
|
||||||
deleted, added := compareUserList(c.userList, newUserInfo)
|
deleted, added := compareUserList(c.userList, newUserInfo)
|
||||||
if len(deleted) > 0 {
|
if len(deleted) > 0 {
|
||||||
deletedEmail := make([]string, len(deleted))
|
deletedEmail := make([]string, len(deleted))
|
||||||
@ -337,15 +335,15 @@ func (c *Controller) addNewUserFromIndex(userInfo *[]api.UserInfo, userIndex *[]
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compareUserList(old, new *[]api.UserInfo) (deleted, added []int) {
|
func compareUserList(old, new *[]api.UserInfo) (deleted, added []int) {
|
||||||
tmp := map[int]struct{}{}
|
tmp := map[string]struct{}{}
|
||||||
tmp2 := map[int]struct{}{}
|
tmp2 := map[string]struct{}{}
|
||||||
for i := range *old {
|
for i := range *old {
|
||||||
tmp[(*old)[i].UID] = struct{}{}
|
tmp[(*old)[i].GetUserEmail()] = struct{}{}
|
||||||
}
|
}
|
||||||
l := len(tmp)
|
l := len(tmp)
|
||||||
for i := range *new {
|
for i := range *new {
|
||||||
tmp[(*new)[i].UID] = struct{}{}
|
tmp[(*old)[i].GetUserEmail()] = struct{}{}
|
||||||
tmp2[(*new)[i].UID] = struct{}{}
|
tmp2[(*new)[i].GetUserEmail()] = struct{}{}
|
||||||
if l != len(tmp) {
|
if l != len(tmp) {
|
||||||
added = append(added, i)
|
added = append(added, i)
|
||||||
l++
|
l++
|
||||||
@ -354,7 +352,7 @@ func compareUserList(old, new *[]api.UserInfo) (deleted, added []int) {
|
|||||||
tmp = nil
|
tmp = nil
|
||||||
l = len(tmp2)
|
l = len(tmp2)
|
||||||
for i := range *old {
|
for i := range *old {
|
||||||
tmp2[(*old)[i].UID] = struct{}{}
|
tmp2[(*old)[i].GetUserEmail()] = struct{}{}
|
||||||
if l != len(tmp2) {
|
if l != len(tmp2) {
|
||||||
deleted = append(deleted, i)
|
deleted = append(deleted, i)
|
||||||
l++
|
l++
|
||||||
|
Loading…
Reference in New Issue
Block a user