Skip to content

Commit 0a6f10c

Browse files
committed
Add support proxypanel
1 parent 291fbc2 commit 0a6f10c

File tree

9 files changed

+906
-23
lines changed

9 files changed

+906
-23
lines changed

api/apimodel.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type NodeInfo struct {
2929
SpeedLimit uint64 // Bps
3030
AlterID int
3131
TransportProtocol string
32+
FakeType string
3233
Host string
3334
Path string
3435
EnableTLS bool

api/pmpanel/pmpanel.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ func (c *APIClient) ReportUserTraffic(userTraffic *[]api.UserTraffic) error {
280280

281281
// GetNodeRule will pull the audit rule form sspanel
282282
func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
283+
ruleList := c.LocalRuleList
283284
path := "/mod_mu/func/detect_rules"
284285
res, err := c.client.R().
285286
SetResult(&Response{}).
@@ -293,12 +294,12 @@ func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
293294
if err := json.Unmarshal(response.Data, ruleListResponse); err != nil {
294295
return nil, fmt.Errorf("Unmarshal %s failed: %s", reflect.TypeOf(ruleListResponse), err)
295296
}
296-
ruleList := make([]api.DetectRule, len(*ruleListResponse))
297-
for i, r := range *ruleListResponse {
298-
ruleList[i] = api.DetectRule{
297+
298+
for _, r := range *ruleListResponse {
299+
ruleList = append(ruleList, api.DetectRule{
299300
ID: r.ID,
300301
Pattern: r.Content,
301-
}
302+
})
302303
}
303304
return &ruleList, nil
304305
}

api/proxypanel/model.go

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package proxypanel
2+
3+
import "encoding/json"
4+
5+
type Response struct {
6+
Status string `json:"status"`
7+
Code int `json:"code"`
8+
Data json.RawMessage `json:"data"`
9+
Message string `json:"message"`
10+
}
11+
12+
type V2rayNodeInfo struct {
13+
ID int `json:"id"`
14+
IsUDP bool `json:"is_udp"`
15+
SpeedLimit uint64 `json:"speed_limit"`
16+
ClientLimit int `json:"client_limit"`
17+
PushPort int `json:"push_port"`
18+
Secret string `json:"secret"`
19+
Key string `json:"key"`
20+
Cert string `json:"pem"`
21+
V2License string `json:"v2_license"`
22+
V2AlterID int `json:"v2_alter_id"`
23+
V2Port int `json:"v2_port"`
24+
V2Method string `json:"v2_method"`
25+
V2Net string `json:"v2_net"`
26+
V2Type string `json:"v2_type"`
27+
V2Host string `json:"v2_host"`
28+
V2Path string `json:"v2_path"`
29+
V2TLS bool `json:"v2_tls"`
30+
V2Cdn bool `json:"v2_cdn"`
31+
V2TLSProvider string `json:"v2_tls_provider"`
32+
RedirectUrl string `json:"redirect_url"`
33+
}
34+
35+
type ShadowsocksNodeInfo struct {
36+
ID int `json:"id"`
37+
IsUDP int `json:"is_udp"`
38+
SpeedLimit uint64 `json:"speed_limit"`
39+
ClientLimit int `json:"client_limit"`
40+
PushPort int `json:"push_port"`
41+
Method string `json:"method"`
42+
Protocol string `json:"protocol"`
43+
Obfs string `json:"obfs"`
44+
Obfs_param string `json:"obfs_param"`
45+
Single int `json:"sinlge"`
46+
Port string `json:"port"`
47+
Passwd string `json:"Passwd"`
48+
}
49+
50+
type TrojanNodeInfo struct {
51+
ID int `json:"id"`
52+
IsUDP bool `json:"is_udp"`
53+
SpeedLimit uint64 `json:"speed_limit"`
54+
ClientLimit int `json:"client_limit"`
55+
PushPort int `json:"push_port"`
56+
TrojanPort int `json:"trojan_port"`
57+
}
58+
59+
// Node status report
60+
type NodeStatus struct {
61+
CPU string `json:"cpu"`
62+
Mem string `json:"mem"`
63+
Net string `json:"net"`
64+
Disk string `json:"disk"`
65+
Uptime int `json:"uptime"`
66+
}
67+
68+
type NodeOnline struct {
69+
UID int `json:"uid"`
70+
IP string `json:"ip"`
71+
}
72+
73+
type VMessUser struct {
74+
UID int `json:"uid"`
75+
VmessUID string `json:"vmess_uid"`
76+
SpeedLimit uint64 `json:"speed_limit"`
77+
}
78+
79+
type TrojanUser struct {
80+
UID int `json:"uid"`
81+
Password string `json:"password"`
82+
SpeedLimit uint64 `json:"speed_limit"`
83+
}
84+
85+
type SSUser struct {
86+
UID int `json:"uid"`
87+
Password string `json:"assword"`
88+
Method string `json:"method"`
89+
SpeedLimit uint64 `json:"speed_limit"`
90+
}
91+
92+
type UserTraffic struct {
93+
UID int `json:"uid"`
94+
Upload int64 `json:"upload"`
95+
Download int64 `json:"download"`
96+
}
97+
98+
type NodeRule struct {
99+
Mode string `json:"mode"`
100+
Rules []NodeRuleItem `json:"rules"`
101+
}
102+
103+
type NodeRuleItem struct {
104+
ID int `json:"id"`
105+
Type string `json:"type"`
106+
Pattern string `json:"pattern"`
107+
}
108+
109+
// IllegalReport
110+
type IllegalReport struct {
111+
UID int `json:"uid"`
112+
RuleID int `json:"rule_id"`
113+
Reason string `json:"reason"`
114+
}
115+
116+
type Certificate struct {
117+
Key string `json:"key"`
118+
Pem string `json:"pem"`
119+
}

0 commit comments

Comments
 (0)