mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 13:41:23 +08:00
feat: rule-provider support rules field
This commit is contained in:
parent
7db07630a7
commit
259736390a
@ -64,6 +64,9 @@ func parseRule(tp, payload, target string, params []string) (C.Rule, error) {
|
|||||||
parsed = RC.NewDomainSuffix(payload, target)
|
parsed = RC.NewDomainSuffix(payload, target)
|
||||||
case "DOMAIN-KEYWORD":
|
case "DOMAIN-KEYWORD":
|
||||||
parsed = RC.NewDomainKeyword(payload, target)
|
parsed = RC.NewDomainKeyword(payload, target)
|
||||||
|
case "GEOIP":
|
||||||
|
noResolve := RC.HasNoResolve(params)
|
||||||
|
parsed, parseErr = RC.NewGEOIP(payload, target, noResolve)
|
||||||
case "GEOSITE":
|
case "GEOSITE":
|
||||||
parsed, parseErr = RC.NewGEOSITE(payload, target)
|
parsed, parseErr = RC.NewGEOSITE(payload, target)
|
||||||
case "IP-CIDR", "IP-CIDR6":
|
case "IP-CIDR", "IP-CIDR6":
|
||||||
@ -79,9 +82,6 @@ func parseRule(tp, payload, target string, params []string) (C.Rule, error) {
|
|||||||
parsed, parseErr = RC.NewProcess(payload, target, true)
|
parsed, parseErr = RC.NewProcess(payload, target, true)
|
||||||
case "PROCESS-PATH":
|
case "PROCESS-PATH":
|
||||||
parsed, parseErr = RC.NewProcess(payload, target, false)
|
parsed, parseErr = RC.NewProcess(payload, target, false)
|
||||||
case "GEOIP":
|
|
||||||
noResolve := RC.HasNoResolve(params)
|
|
||||||
parsed, parseErr = RC.NewGEOIP(payload, target, noResolve)
|
|
||||||
default:
|
default:
|
||||||
parseErr = fmt.Errorf("unsupported rule type %s", tp)
|
parseErr = fmt.Errorf("unsupported rule type %s", tp)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,8 @@ type RulePayload struct {
|
|||||||
key: Domain or IP Cidr
|
key: Domain or IP Cidr
|
||||||
value: Rule type or is empty
|
value: Rule type or is empty
|
||||||
*/
|
*/
|
||||||
Rules []string `yaml:"payload"`
|
Rules []string `yaml:"payload"`
|
||||||
|
Rules2 []string `yaml:"rules"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ruleStrategy interface {
|
type ruleStrategy interface {
|
||||||
@ -144,5 +145,5 @@ func rulesParse(buf []byte) (interface{}, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return rulePayload.Rules, nil
|
return append(rulePayload.Rules, rulePayload.Rules2...), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user