Skip to content

Commit

Permalink
optimization and reduce the size of the data passed by api
Browse files Browse the repository at this point in the history
  • Loading branch information
theresaarcher committed Jul 27, 2024
1 parent 86e44d2 commit e4deba1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v2raysocks/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type NodeOnline struct {
IP string `json:"ip"`
}

type IllegalItem struct {
UID int `json:"user_id"`
}

type REALITYConfig struct {
Dest string `json:"dest,omitempty"`
ProxyProtocolVer uint64 `json:"proxy_protocol_ver,omitempty"`
Expand Down
20 changes: 20 additions & 0 deletions api/v2raysocks/v2raysocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,26 @@ func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) erro

// ReportIllegal implements the API interface
func (c *APIClient) ReportIllegal(detectResultList *[]api.DetectResult) error {
data := make([]IllegalItem, len(*detectResultList))
for i, r := range *detectResultList {
data[i] = IllegalItem{
UID: r.UID,
}
}

res, err := c.client.R().
SetQueryParam("node_id", strconv.Itoa(c.NodeID)).
SetQueryParams(map[string]string{
"act": "illegal",
"node_type": strings.ToLower(c.NodeType),
}).
SetBody(data).
ForceContentType("application/json").
Post(c.APIHost)
_, err = c.parseResponse(res, "", err)
if err != nil {
return err
}
return nil
}

Expand Down

0 comments on commit e4deba1

Please sign in to comment.