From c52e689d0d8e056a56e81f96ba0422bcb3d9b28a Mon Sep 17 00:00:00 2001 From: Skyxim Date: Sat, 4 Jun 2022 19:12:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20classical=20rule-set=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=9C=AA=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/provider/classical_strategy.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rule/provider/classical_strategy.go b/rule/provider/classical_strategy.go index 4ce69389..297ad32f 100644 --- a/rule/provider/classical_strategy.go +++ b/rule/provider/classical_strategy.go @@ -30,20 +30,24 @@ func (c *classicalStrategy) ShouldResolveIP() bool { } func (c *classicalStrategy) OnUpdate(rules []string) { + var classicalRules []C.Rule + shouldResolveIP := false for _, rawRule := range rules { ruleType, rule, params := ruleParse(rawRule) r, err := parseRule(ruleType, rule, "", params) if err != nil { log.Warnln("parse rule error:[%s]", err.Error()) } else { - if !c.shouldResolveIP { - c.shouldResolveIP = r.ShouldResolveIP() + if !shouldResolveIP { + shouldResolveIP = r.ShouldResolveIP() } - c.rules = append(c.rules, r) - c.count++ + classicalRules = append(classicalRules, r) } } + + c.rules = classicalRules + c.count = len(classicalRules) } func NewClassicalStrategy() *classicalStrategy {