From f7d5d891c3d4001f6d98bfba219450574549148e Mon Sep 17 00:00:00 2001 From: wyx2685 Date: Thu, 12 Sep 2024 00:10:31 +0900 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E5=92=8C=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=E6=97=B6=E6=9C=AA?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E9=87=8D=E7=BD=AE=E8=B5=84=E6=BA=90=E7=9A=84?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/panel/user.go | 39 ++++++++++++++++++++------------------- core/xray/inbound.go | 5 ----- limiter/limiter.go | 2 ++ 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/api/panel/user.go b/api/panel/user.go index edf9228..3bbb424 100644 --- a/api/panel/user.go +++ b/api/panel/user.go @@ -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 { - defer r.RawResponse.Body.Close() - } else { - return nil, fmt.Errorf("received nil response") + if r == nil || r.RawResponse == nil { + return nil, fmt.Errorf("received nil response or raw response") } + defer r.RawResponse.Body.Close() if r.StatusCode() == 304 { return nil, nil - } else { - if err := json.Unmarshal(r.Body(), c.UserList); err != nil { - return nil, fmt.Errorf("unmarshal user list error: %w", err) - } - c.userEtag = r.Header().Get("ETag") } - return c.UserList.Users, 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 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") } + defer r.RawResponse.Body.Close() - 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 { diff --git a/core/xray/inbound.go b/core/xray/inbound.go index 18d8492..d5b3e1c 100644 --- a/core/xray/inbound.go +++ b/core/xray/inbound.go @@ -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 { diff --git a/limiter/limiter.go b/limiter/limiter.go index 6f59822..39aa3db 100644 --- a/limiter/limiter.go +++ b/limiter/limiter.go @@ -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{