[Skip CI]

This commit is contained in:
MetaCubeX
2022-03-15 02:20:19 +08:00
parent cf52fbed65
commit 68fccfacc0
10 changed files with 56 additions and 13 deletions

View File

@ -81,9 +81,9 @@ func (rp *ruleSetProvider) Match(metadata *C.Metadata) bool {
switch rp.behavior {
case P.Domain:
return rp.DomainRules.Search(metadata.Host) != nil
return rp.DomainRules != nil && rp.DomainRules.Search(metadata.Host) != nil
case P.IPCIDR:
return rp.IPCIDRRules.IsContain(metadata.DstIP)
return rp.IPCIDRRules != nil && rp.IPCIDRRules.IsContain(metadata.DstIP)
case P.Classical:
for _, rule := range rp.ClassicalRules {
if rule.Match(metadata) {
@ -124,12 +124,12 @@ func NewRuleSetProvider(name string, behavior P.RuleType, interval time.Duration
onUpdate := func(elm interface{}) error {
rulesRaw := elm.([]string)
rp.count = len(rulesRaw)
rules, err := constructRules(rp.behavior, rulesRaw)
if err != nil {
return err
}
rp.count = len(rulesRaw)
rp.setRules(rules)
return nil
}