mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
d6dc5ba19c
rules: - SUB-RULE,(AND,((NETWORK,TCP),(DOMAIN-KEYWORD,google))),TEST2 - SUB-RULE,(GEOIP,!CN),TEST1 - MATCH,DIRECT sub-rules: TEST2: - MATCH,Proxy TEST1: - RULE-SET,Local,DIRECT,no-resolve - GEOSITE,CN,Domestic - GEOIP,CN,Domestic - MATCH,Proxy
90 lines
1.2 KiB
Go
90 lines
1.2 KiB
Go
package constant
|
|
|
|
// Rule Type
|
|
const (
|
|
Domain RuleType = iota
|
|
DomainSuffix
|
|
DomainKeyword
|
|
GEOSITE
|
|
GEOIP
|
|
IPCIDR
|
|
SrcIPCIDR
|
|
IPSuffix
|
|
SrcIPSuffix
|
|
SrcPort
|
|
DstPort
|
|
Process
|
|
ProcessPath
|
|
RuleSet
|
|
Network
|
|
Uid
|
|
INTYPE
|
|
SubRules
|
|
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 IPSuffix:
|
|
return "IPSuffix"
|
|
case SrcIPSuffix:
|
|
return "SrcIPSuffix"
|
|
case SrcPort:
|
|
return "SrcPort"
|
|
case DstPort:
|
|
return "DstPort"
|
|
case Process:
|
|
return "Process"
|
|
case ProcessPath:
|
|
return "ProcessPath"
|
|
case MATCH:
|
|
return "Match"
|
|
case RuleSet:
|
|
return "RuleSet"
|
|
case Network:
|
|
return "Network"
|
|
case Uid:
|
|
return "Uid"
|
|
case INTYPE:
|
|
return "InType"
|
|
case SubRules:
|
|
return "SubRules"
|
|
case AND:
|
|
return "AND"
|
|
case OR:
|
|
return "OR"
|
|
case NOT:
|
|
return "NOT"
|
|
default:
|
|
return "Unknown"
|
|
}
|
|
}
|
|
|
|
type Rule interface {
|
|
RuleType() RuleType
|
|
Match(metadata *Metadata) (bool, string)
|
|
Adapter() string
|
|
Payload() string
|
|
ShouldResolveIP() bool
|
|
ShouldFindProcess() bool
|
|
}
|