Skip to content

Commit

Permalink
Fixed:Rule-Set Supported RuleExtra
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyxim committed Dec 2, 2021
1 parent 6369921 commit b99b4ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rule/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ParseRule(tp, payload, target string, params []string) (C.Rule, error) {
case "MATCH":
parsed = NewMatch(target, ruleExtra)
case "RULE-SET":
parsed, parseErr = NewRuleSet(payload, target)
parsed, parseErr = NewRuleSet(payload, target, ruleExtra)
default:
parseErr = fmt.Errorf("unsupported rule type %s", tp)
}
Expand Down
4 changes: 3 additions & 1 deletion rule/rule_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type RuleSet struct {
ruleProviderName string
adapter string
ruleProvider *P.RuleProvider
ruleExtra *C.RuleExtra
}

func (rs *RuleSet) RuleType() C.RuleType {
Expand Down Expand Up @@ -44,7 +45,7 @@ func (rs *RuleSet) RuleExtra() *C.RuleExtra {
return nil
}

func NewRuleSet(ruleProviderName string, adapter string) (*RuleSet, error) {
func NewRuleSet(ruleProviderName string, adapter string, ruleExtra *C.RuleExtra) (*RuleSet, error) {
rp, ok := RuleProviders()[ruleProviderName]
if !ok {
return nil, fmt.Errorf("rule set %s not found", ruleProviderName)
Expand All @@ -53,5 +54,6 @@ func NewRuleSet(ruleProviderName string, adapter string) (*RuleSet, error) {
ruleProviderName: ruleProviderName,
adapter: adapter,
ruleProvider: rp,
ruleExtra: ruleExtra,
}, nil
}

0 comments on commit b99b4ad

Please sign in to comment.