-
Notifications
You must be signed in to change notification settings - Fork 5
/
model.go
91 lines (77 loc) · 2.25 KB
/
model.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
package main
import (
"math"
"net"
"time"
)
type Version struct {
Premium bool `json:"premium"`
Version string `json:"version"`
}
// see clash/constant/adapters.go#AdapterType.String
var (
ConnectionProxyTypes = []string{"Shadowsocks", "ShadowsocksR", "Snell", "Socks5", "Http", "Vmess", "Trojan"}
RuleProxyTypes = []string{"Direct", "Reject", "Relay", "Selector", "Fallback", "URLTest", "LoadBalance"}
AllProxyTypes []string
connectionProxyTypeSet = make(map[string]struct{}, len(ConnectionProxyTypes))
)
func init() {
AllProxyTypes = append(AllProxyTypes, ConnectionProxyTypes...)
AllProxyTypes = append(AllProxyTypes, RuleProxyTypes...)
for _, t := range ConnectionProxyTypes {
connectionProxyTypeSet[t] = struct{}{}
}
}
func IsConnectionProxy(proxy *Proxy) bool {
_, ok := connectionProxyTypeSet[proxy.Type]
return ok
}
const MaxDelay = math.MaxUint16
type ProxyDelay struct {
Time time.Time `json:"time"`
Delay uint16 `json:"delay"`
}
type Proxy struct {
Type string
Name string
Now string
All []string
History []*ProxyDelay `json:"history"`
}
const (
VehicleTypeFile = "File"
VehicleTypeHTTP = "HTTP"
VehicleTypeCompatible = "Compatible"
)
type Provider struct {
Type string `json:"type"`
Name string `json:"name"`
VehicleType string `json:"vehicleType"`
UpdatedAt time.Time `json:"updatedAt"`
Proxies []*Proxy `json:"proxies"`
}
type Metadata struct {
NetWork string `json:"network"`
Type string `json:"type"`
SrcIP net.IP `json:"sourceIP"`
DstIP net.IP `json:"destinationIP"`
SrcPort string `json:"sourcePort"`
DstPort string `json:"destinationPort"`
AddrType int `json:"-"`
Host string `json:"host"`
}
type TrackerInfo struct {
UUID string `json:"id"`
Metadata *Metadata `json:"metadata"`
UploadTotal int64 `json:"upload"`
DownloadTotal int64 `json:"download"`
Start time.Time `json:"start"`
Chain []string `json:"chains"`
Rule string `json:"rule"`
RulePayload string `json:"rulePayload"`
}
type Snapshot struct {
DownloadTotal int64 `json:"downloadTotal"`
UploadTotal int64 `json:"uploadTotal"`
Connections []*TrackerInfo `json:"connections"`
}