feat: IN-TYPE rule support
eg. IN-TYPE,SOCKS/REDIR/INNER,Proxy support list: HTTP HTTPS SOCKS SOCKS4 SOCKS5 REDIR TPROXY TUN INNER
This commit is contained in:
@ -19,7 +19,7 @@ const (
|
||||
ALLNet
|
||||
|
||||
HTTP Type = iota
|
||||
HTTPCONNECT
|
||||
HTTPS
|
||||
SOCKS4
|
||||
SOCKS5
|
||||
REDIR
|
||||
@ -49,8 +49,8 @@ func (t Type) String() string {
|
||||
switch t {
|
||||
case HTTP:
|
||||
return "HTTP"
|
||||
case HTTPCONNECT:
|
||||
return "HTTP Connect"
|
||||
case HTTPS:
|
||||
return "HTTPS"
|
||||
case SOCKS4:
|
||||
return "Socks4"
|
||||
case SOCKS5:
|
||||
@ -68,6 +68,31 @@ func (t Type) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
func ParseType(t string) (*Type, error) {
|
||||
var res Type
|
||||
switch t {
|
||||
case "HTTP":
|
||||
res = HTTP
|
||||
case "HTTPS":
|
||||
res = HTTPS
|
||||
case "SOCKS4":
|
||||
res = SOCKS4
|
||||
case "SOCKS5":
|
||||
res = SOCKS5
|
||||
case "REDIR":
|
||||
res = REDIR
|
||||
case "TPROXY":
|
||||
res = TPROXY
|
||||
case "TUN":
|
||||
res = TUN
|
||||
case "INNER":
|
||||
res = INNER
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown type: %s", t)
|
||||
}
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func (t Type) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(t.String())
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ const (
|
||||
RuleSet
|
||||
Network
|
||||
Uid
|
||||
INTYPE
|
||||
MATCH
|
||||
AND
|
||||
OR
|
||||
@ -56,6 +57,8 @@ func (rt RuleType) String() string {
|
||||
return "Network"
|
||||
case Uid:
|
||||
return "Uid"
|
||||
case INTYPE:
|
||||
return "InType"
|
||||
case AND:
|
||||
return "AND"
|
||||
case OR:
|
||||
|
Reference in New Issue
Block a user