mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 09:58:14 -05:00
Fix:修复获取用户列表和在线设备列表时未正常重置资源的BUG
This commit is contained in:
parent
6936a76724
commit
f7d5d891c3
@ -34,24 +34,24 @@ func (c *Client) GetUserList() ([]UserInfo, error) {
|
||||
SetHeader("If-None-Match", c.userEtag).
|
||||
ForceContentType("application/json").
|
||||
Get(path)
|
||||
if err = c.checkResponse(r, path, err); err != nil {
|
||||
return nil, err
|
||||
if r == nil || r.RawResponse == nil {
|
||||
return nil, fmt.Errorf("received nil response or raw response")
|
||||
}
|
||||
if r != nil {
|
||||
defer r.RawResponse.Body.Close()
|
||||
} else {
|
||||
return nil, fmt.Errorf("received nil response")
|
||||
}
|
||||
|
||||
if r.StatusCode() == 304 {
|
||||
return nil, nil
|
||||
} else {
|
||||
if err := json.Unmarshal(r.Body(), c.UserList); err != nil {
|
||||
}
|
||||
|
||||
if err = c.checkResponse(r, path, err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
userlist := &UserListBody{}
|
||||
if err := json.Unmarshal(r.Body(), userlist); err != nil {
|
||||
return nil, fmt.Errorf("unmarshal user list error: %w", err)
|
||||
}
|
||||
c.userEtag = r.Header().Get("ETag")
|
||||
}
|
||||
return c.UserList.Users, nil
|
||||
return userlist.Users, nil
|
||||
}
|
||||
|
||||
// GetUserAlive will fetch the alive_ip count for users
|
||||
@ -60,14 +60,15 @@ func (c *Client) GetUserAlive() (map[int]int, error) {
|
||||
r, err := c.client.R().
|
||||
ForceContentType("application/json").
|
||||
Get(path)
|
||||
if err != nil || r.StatusCode() >= 399 {
|
||||
return make(map[int]int), nil
|
||||
if r == nil || r.RawResponse == nil {
|
||||
return nil, fmt.Errorf("received nil response or raw response")
|
||||
}
|
||||
|
||||
if r != nil {
|
||||
defer r.RawResponse.Body.Close()
|
||||
} else {
|
||||
return nil, fmt.Errorf("received nil response")
|
||||
|
||||
c.AliveMap = &AliveMap{}
|
||||
if err != nil || r.StatusCode() >= 399 {
|
||||
c.AliveMap.Alive = make(map[int]int)
|
||||
return c.AliveMap.Alive, nil
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(r.Body(), c.AliveMap); err != nil {
|
||||
|
@ -213,11 +213,6 @@ func buildV2ray(config *conf.Options, nodeInfo *panel.NodeInfo, inbound *coreCon
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshal grpc settings error: %s", err)
|
||||
}
|
||||
case "quic":
|
||||
err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.QUICSettings)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unmarshal grpc settings error: %s", err)
|
||||
}
|
||||
case "httpupgrade":
|
||||
err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.HTTPUPGRADESettings)
|
||||
if err != nil {
|
||||
|
@ -104,7 +104,9 @@ func DeleteLimiter(tag string) {
|
||||
func (l *Limiter) UpdateUser(tag string, added []panel.UserInfo, deleted []panel.UserInfo) {
|
||||
for i := range deleted {
|
||||
l.UserLimitInfo.Delete(format.UserTag(tag, deleted[i].Uuid))
|
||||
l.UserOnlineIP.Delete(format.UserTag(tag, deleted[i].Uuid))
|
||||
delete(l.UUIDtoUID, deleted[i].Uuid)
|
||||
delete(l.AliveList, deleted[i].Id)
|
||||
}
|
||||
for i := range added {
|
||||
userLimit := &UserLimitInfo{
|
||||
|
Loading…
Reference in New Issue
Block a user