-
Notifications
You must be signed in to change notification settings - Fork 920
/
Copy pathv2raysocks_test.go
102 lines (90 loc) · 1.91 KB
/
v2raysocks_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package v2raysocks_test
import (
"testing"
"github.com/XrayR-project/XrayR/api"
"github.com/XrayR-project/XrayR/api/v2raysocks"
)
func CreateClient() api.API {
apiConfig := &api.Config{
APIHost: "https://127.0.0.1/",
Key: "123456789",
NodeID: 280002,
NodeType: "V2ray",
}
client := v2raysocks.New(apiConfig)
return client
}
func TestGetV2rayNodeinfo(t *testing.T) {
client := CreateClient()
client.Debug()
nodeInfo, err := client.GetNodeInfo()
if err != nil {
t.Error(err)
}
t.Log(nodeInfo)
}
func TestGetSSNodeinfo(t *testing.T) {
apiConfig := &api.Config{
APIHost: "https://127.0.0.1/",
Key: "123456789",
NodeID: 280009,
NodeType: "Shadowsocks",
}
client := v2raysocks.New(apiConfig)
nodeInfo, err := client.GetNodeInfo()
if err != nil {
t.Error(err)
}
t.Log(nodeInfo)
}
func TestGetTrojanNodeinfo(t *testing.T) {
apiConfig := &api.Config{
APIHost: "https://127.0.0.1/",
Key: "123456789",
NodeID: 280008,
NodeType: "Trojan",
}
client := v2raysocks.New(apiConfig)
nodeInfo, err := client.GetNodeInfo()
if err != nil {
t.Error(err)
}
t.Log(nodeInfo)
}
func TestGetUserList(t *testing.T) {
client := CreateClient()
userList, err := client.GetUserList()
if err != nil {
t.Error(err)
}
t.Log(userList)
}
func TestReportReportUserTraffic(t *testing.T) {
client := CreateClient()
userList, err := client.GetUserList()
if err != nil {
t.Error(err)
}
generalUserTraffic := make([]api.UserTraffic, len(*userList))
for i, userInfo := range *userList {
generalUserTraffic[i] = api.UserTraffic{
UID: userInfo.UID,
Upload: 114514,
Download: 114514,
}
}
// client.Debug()
err = client.ReportUserTraffic(&generalUserTraffic)
if err != nil {
t.Error(err)
}
}
func TestGetNodeRule(t *testing.T) {
client := CreateClient()
client.Debug()
ruleList, err := client.GetNodeRule()
if err != nil {
t.Error(err)
}
t.Log(ruleList)
}