mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-08 13:29:54 +00:00
add 2 acts to V2RaySocks (#516)
This commit is contained in:
parent
c04d52330d
commit
78c2e31bdf
@ -5,3 +5,16 @@ type UserTraffic struct {
|
||||
Upload int64 `json:"u"`
|
||||
Download int64 `json:"d"`
|
||||
}
|
||||
|
||||
type NodeStatus struct {
|
||||
CPU string `json:"cpu"`
|
||||
Mem string `json:"mem"`
|
||||
Net string `json:"net"`
|
||||
Disk string `json:"disk"`
|
||||
Uptime int `json:"uptime"`
|
||||
}
|
||||
|
||||
type NodeOnline struct {
|
||||
UID int `json:"uid"`
|
||||
IP string `json:"ip"`
|
||||
}
|
@ -287,11 +287,49 @@ func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
|
||||
|
||||
// ReportNodeStatus implements the API interface
|
||||
func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error) {
|
||||
systemload := NodeStatus{
|
||||
Uptime: int(nodeStatus.Uptime),
|
||||
CPU: fmt.Sprintf("%d%%", int(nodeStatus.CPU)),
|
||||
Mem: fmt.Sprintf("%d%%", int(nodeStatus.Mem)),
|
||||
Disk: fmt.Sprintf("%d%%", int(nodeStatus.Disk)),
|
||||
}
|
||||
|
||||
res, err := c.client.R().
|
||||
SetQueryParam("node_id", strconv.Itoa(c.NodeID)).
|
||||
SetQueryParams(map[string]string{
|
||||
"act": "nodestatus",
|
||||
"nodetype": strings.ToLower(c.NodeType),
|
||||
}).
|
||||
SetBody(systemload).
|
||||
ForceContentType("application/json").
|
||||
Post(c.APIHost)
|
||||
_, err = c.parseResponse(res, "", err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReportNodeOnlineUsers implements the API interface
|
||||
func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) error {
|
||||
data := make([]NodeOnline, len(*onlineUserList))
|
||||
for i, user := range *onlineUserList {
|
||||
data[i] = NodeOnline{UID: user.UID, IP: user.IP}
|
||||
}
|
||||
|
||||
res, err := c.client.R().
|
||||
SetQueryParam("node_id", strconv.Itoa(c.NodeID)).
|
||||
SetQueryParams(map[string]string{
|
||||
"act": "onlineusers",
|
||||
"nodetype": strings.ToLower(c.NodeType),
|
||||
}).
|
||||
SetBody(data).
|
||||
ForceContentType("application/json").
|
||||
Post(c.APIHost)
|
||||
_, err = c.parseResponse(res, "", err)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user