mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 18:08:14 -05:00
fix report bug
This commit is contained in:
parent
a3717c1e63
commit
b07c9f0b6b
@ -4,7 +4,6 @@ import (
|
||||
"github.com/goccy/go-json"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type NodeInfo struct {
|
||||
@ -62,12 +61,10 @@ func (c *Client) GetNodeInfo() (nodeInfo *NodeInfo, err error) {
|
||||
nodeInfo.NodeType = c.NodeType
|
||||
for i := range nodeInfo.Routes { // parse rules from routes
|
||||
if nodeInfo.Routes[i].Action == "block" {
|
||||
for _, v := range strings.Split(nodeInfo.Routes[i].Match, ",") {
|
||||
nodeInfo.Rules = append(nodeInfo.Rules, DestinationRule{
|
||||
ID: nodeInfo.Routes[i].Id,
|
||||
Pattern: regexp.MustCompile(v),
|
||||
})
|
||||
}
|
||||
nodeInfo.Rules = append(nodeInfo.Rules, DestinationRule{
|
||||
ID: nodeInfo.Routes[i].Id,
|
||||
Pattern: regexp.MustCompile(nodeInfo.Routes[i].Match),
|
||||
})
|
||||
}
|
||||
}
|
||||
nodeInfo.Routes = nil
|
||||
|
@ -6,7 +6,9 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestClient_GetNodeInfo(t *testing.T) {
|
||||
var client Panel
|
||||
|
||||
func init() {
|
||||
c, err := New(&conf.ApiConfig{
|
||||
APIHost: "http://127.0.0.1",
|
||||
Key: "token",
|
||||
@ -14,7 +16,21 @@ func TestClient_GetNodeInfo(t *testing.T) {
|
||||
NodeID: 1,
|
||||
})
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
log.Panic(err)
|
||||
}
|
||||
log.Println(c.GetNodeInfo())
|
||||
client = c
|
||||
}
|
||||
|
||||
func TestClient_GetNodeInfo(t *testing.T) {
|
||||
log.Println(client.GetNodeInfo())
|
||||
}
|
||||
|
||||
func TestClient_ReportUserTraffic(t *testing.T) {
|
||||
log.Println(client.ReportUserTraffic([]UserTraffic{
|
||||
{
|
||||
UID: 10372,
|
||||
Upload: 1000,
|
||||
Download: 1000,
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func (c *Client) ReportUserTraffic(userTraffic []UserTraffic) error {
|
||||
}
|
||||
const path = "/api/v1/server/UniProxy/push"
|
||||
res, err := c.client.R().
|
||||
SetBody(userTraffic).
|
||||
SetBody(data).
|
||||
ForceContentType("application/json").
|
||||
Post(path)
|
||||
err = c.checkResponse(res, path, err)
|
||||
|
Loading…
Reference in New Issue
Block a user