Skip to content

Commit

Permalink
fix: invalid rules
Browse files Browse the repository at this point in the history
  • Loading branch information
igoogolx committed Dec 28, 2023
1 parent 6d8785f commit 1d8a517
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/cfg/distribution/ruleEngine/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func (d Domain) Value() string {
return d.Payload
}

func NewDomainRule(payload, policy string) (*Domain, error) {
return &Domain{constants.RuleDomain, payload, policy}, nil
func NewDomainRule(ruleType constants.RuleConfig, payload, policy string) (*Domain, error) {
return &Domain{ruleType, payload, policy}, nil
}

func isContainsDomain(rType constants.RuleConfig, value string, s string) bool {
Expand Down
8 changes: 7 additions & 1 deletion internal/cfg/distribution/ruleEngine/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,16 @@ func ParseItem(rawRuleType, value, policy string) (Rule, error) {
rule, err = NewIpCidrRule(value, policy)
break
case constants.RuleDomain:
rule, err = NewDomainRule(ruleType, value, policy)
break
case constants.RuleDomainKeyword:
rule, err = NewDomainRule(ruleType, value, policy)
break
case constants.RuleDomainSuffix:
rule, err = NewDomainRule(ruleType, value, policy)
break
case constants.RuleDomainRegex:
rule, err = NewDomainRule(value, policy)
rule, err = NewDomainRule(ruleType, value, policy)
break
default:
err = fmt.Errorf("rule type not match: %v", ruleType)
Expand Down

0 comments on commit 1d8a517

Please sign in to comment.