Code: refresh code

This commit is contained in:
yaling888
2021-07-01 22:49:29 +08:00
parent 3ca5d17c40
commit d7732f6ebc
104 changed files with 11329 additions and 136 deletions

View File

@ -18,6 +18,7 @@ const (
Socks5
Http
Vmess
Vless
Trojan
Relay
@ -132,6 +133,8 @@ func (at AdapterType) String() string {
return "Http"
case Vmess:
return "Vmess"
case Vless:
return "Vless"
case Trojan:
return "Trojan"

View File

@ -14,12 +14,14 @@ const (
TCP NetWork = iota
UDP
ALLNet
HTTP Type = iota
HTTPCONNECT
SOCKS
REDIR
TPROXY
TUN
)
type NetWork int
@ -27,8 +29,10 @@ type NetWork int
func (n NetWork) String() string {
if n == TCP {
return "tcp"
} else if n == UDP {
return "udp"
}
return "udp"
return "all"
}
func (n NetWork) MarshalJSON() ([]byte, error) {
@ -49,6 +53,8 @@ func (t Type) String() string {
return "Redir"
case TPROXY:
return "TProxy"
case TUN:
return "Tun"
default:
return "Unknown"
}
@ -68,6 +74,7 @@ type Metadata struct {
DstPort string `json:"destinationPort"`
AddrType int `json:"-"`
Host string `json:"host"`
Process string `json:"process"`
}
func (m *Metadata) RemoteAddress() string {

View File

@ -60,3 +60,15 @@ func (p *path) MMDB() string {
func (p *path) Cache() string {
return P.Join(p.homeDir, ".cache")
}
func (p *path) GeoIP() string {
return P.Join(p.homeDir, "geoip.dat")
}
func (p *path) GeoSite() string {
return P.Join(p.homeDir, "geosite.dat")
}
func (p *path) GetAssetLocation(file string) string {
return P.Join(p.homeDir, file)
}

View File

@ -5,6 +5,7 @@ const (
Domain RuleType = iota
DomainSuffix
DomainKeyword
GEOSITE
GEOIP
IPCIDR
SrcIPCIDR
@ -24,6 +25,8 @@ func (rt RuleType) String() string {
return "DomainSuffix"
case DomainKeyword:
return "DomainKeyword"
case GEOSITE:
return "GeoSite"
case GEOIP:
return "GeoIP"
case IPCIDR:
@ -49,4 +52,5 @@ type Rule interface {
Adapter() string
Payload() string
ShouldResolveIP() bool
NetWork() NetWork
}