From 77ec03016ca541deaf29b6356644c5615af7622a Mon Sep 17 00:00:00 2001 From: wyx2685 Date: Sun, 28 Jan 2024 01:04:47 +0900 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/panel/user.go | 28 ++++------------------------ go.mod | 3 +-- go.sum | 6 ++---- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/api/panel/user.go b/api/panel/user.go index 5ee1d58..e57b4f9 100644 --- a/api/panel/user.go +++ b/api/panel/user.go @@ -3,10 +3,7 @@ package panel import ( "fmt" - "encoding/json" - - "github.com/bitly/go-simplejson" - "github.com/go-resty/resty/v2" + "github.com/goccy/go-json" ) type OnlineUser struct { @@ -51,12 +48,12 @@ func (c *Client) GetUserList() (UserList []UserInfo, err error) { return nil, fmt.Errorf("received nil response") } var userList *UserListBody - usersResp, err := c.parseResponse(r, path, err) if err != nil { + return nil, fmt.Errorf("read body error: %s", err) + } + if err := json.Unmarshal(r.Body(), &userList); err != nil { return nil, fmt.Errorf("unmarshal userlist error: %s", err) } - b, _ := usersResp.Encode() - json.Unmarshal(b, &userList) c.userEtag = r.Header().Get("ETag") var userinfos []UserInfo @@ -123,20 +120,3 @@ func (c *Client) ReportNodeOnlineUsers(data *map[int][]string, reportOnline *map return nil } - -func (c *Client) parseResponse(res *resty.Response, path string, err error) (*simplejson.Json, error) { - if err != nil { - return nil, fmt.Errorf("request %s failed: %v", c.assembleURL(path), err) - } - - if res.StatusCode() > 399 { - return nil, fmt.Errorf("request %s failed: %s, %v", c.assembleURL(path), res.String(), err) - } - - rtn, err := simplejson.NewJson(res.Body()) - if err != nil { - return nil, fmt.Errorf("ret %s invalid", res.String()) - } - - return rtn, nil -} diff --git a/go.mod b/go.mod index 0c1f1b1..8563cf6 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.21.4 require ( github.com/beevik/ntp v1.2.0 - github.com/bitly/go-simplejson v0.5.1 github.com/fsnotify/fsnotify v1.7.0 github.com/go-acme/lego/v4 v4.13.2 github.com/go-resty/resty/v2 v2.7.0 @@ -222,4 +221,4 @@ require ( lukechampine.com/blake3 v1.2.1 // indirect ) -replace github.com/sagernet/sing-box v1.8.2 => github.com/wyx2685/sing-box_mod v0.0.0-20240127041531-d639d330f343 +replace github.com/sagernet/sing-box v1.8.2 => github.com/wyx2685/sing-box_mod v0.0.0 diff --git a/go.sum b/go.sum index 6a4eac2..8ddadfd 100644 --- a/go.sum +++ b/go.sum @@ -92,8 +92,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow= -github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI= github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= @@ -787,8 +785,8 @@ github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1Y github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs= github.com/vultr/govultr/v2 v2.17.2/go.mod h1:ZFOKGWmgjytfyjeyAdhQlSWwTjh2ig+X49cAp50dzXI= -github.com/wyx2685/sing-box_mod v0.0.0-20240127041531-d639d330f343 h1:vlI3CJFlaQ1XnP4QZ8AI6pzE6zH0qDMnyhqzyPm9esg= -github.com/wyx2685/sing-box_mod v0.0.0-20240127041531-d639d330f343/go.mod h1:aSBnZ9maXq2QvQ1Ij5+5Hhn0/RBO0zYkjtWfr9GFbLo= +github.com/wyx2685/sing-box_mod v0.0.0 h1:IuJekC27gcCx8NkemLfMdcI6LK64tDh6OwLaOHQX2Ng= +github.com/wyx2685/sing-box_mod v0.0.0/go.mod h1:aSBnZ9maXq2QvQ1Ij5+5Hhn0/RBO0zYkjtWfr9GFbLo= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=