mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
8595d6c2e9
1.Add Network rule, match network type(TCP/UDP) 2.Add logic rules(NOT,OR,AND) -AND,((DOMAIN,baidu.com),(NETWORK,UDP)),REJECT (cherry picked from commit d7092e2e37f2c48282c878edea1b2ebc2912b09a)
76 lines
1.0 KiB
Go
76 lines
1.0 KiB
Go
package constant
|
|
|
|
// Rule Type
|
|
const (
|
|
Domain RuleType = iota
|
|
DomainSuffix
|
|
DomainKeyword
|
|
GEOSITE
|
|
GEOIP
|
|
IPCIDR
|
|
SrcIPCIDR
|
|
SrcPort
|
|
DstPort
|
|
Process
|
|
Script
|
|
RuleSet
|
|
Network
|
|
Combination
|
|
MATCH
|
|
AND
|
|
OR
|
|
NOT
|
|
)
|
|
|
|
type RuleType int
|
|
|
|
func (rt RuleType) String() string {
|
|
switch rt {
|
|
case Domain:
|
|
return "Domain"
|
|
case DomainSuffix:
|
|
return "DomainSuffix"
|
|
case DomainKeyword:
|
|
return "DomainKeyword"
|
|
case GEOSITE:
|
|
return "GeoSite"
|
|
case GEOIP:
|
|
return "GeoIP"
|
|
case IPCIDR:
|
|
return "IPCIDR"
|
|
case SrcIPCIDR:
|
|
return "SrcIPCIDR"
|
|
case SrcPort:
|
|
return "SrcPort"
|
|
case DstPort:
|
|
return "DstPort"
|
|
case Process:
|
|
return "Process"
|
|
case Script:
|
|
return "Script"
|
|
case MATCH:
|
|
return "Match"
|
|
case RuleSet:
|
|
return "RuleSet"
|
|
case Network:
|
|
return "Network"
|
|
case AND:
|
|
return "AND"
|
|
case OR:
|
|
return "OR"
|
|
case NOT:
|
|
return "NOT"
|
|
default:
|
|
return "Unknown"
|
|
}
|
|
}
|
|
|
|
type Rule interface {
|
|
RuleType() RuleType
|
|
Match(metadata *Metadata) bool
|
|
Adapter() string
|
|
Payload() string
|
|
ShouldResolveIP() bool
|
|
RuleExtra() *RuleExtra
|
|
}
|