feat: support sub-rule, eg.

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
This commit is contained in:
adlyq
2022-09-06 17:30:35 +08:00
parent a9694fcdc0
commit 9b89ff9f2d
28 changed files with 325 additions and 105 deletions

View File

@ -19,6 +19,7 @@ const (
Network
Uid
INTYPE
SubRules
MATCH
AND
OR
@ -65,6 +66,8 @@ func (rt RuleType) String() string {
return "Uid"
case INTYPE:
return "InType"
case SubRules:
return "SubRules"
case AND:
return "AND"
case OR:
@ -78,7 +81,7 @@ func (rt RuleType) String() string {
type Rule interface {
RuleType() RuleType
Match(metadata *Metadata) bool
Match(metadata *Metadata) (bool, string)
Adapter() string
Payload() string
ShouldResolveIP() bool