diff --git a/cmd/cli/dns_proxy.go b/cmd/cli/dns_proxy.go index 34d0fb0..10a9581 100644 --- a/cmd/cli/dns_proxy.go +++ b/cmd/cli/dns_proxy.go @@ -393,8 +393,7 @@ func (p *prog) upstreamFor(ctx context.Context, defaultUpstreamNum string, lc *c } matchingConfig = &rulematcher.MatchingConfig{ - Order: order, - StopOnFirstMatch: lc.Policy.Matching.StopOnFirstMatch, + Order: order, } } diff --git a/cmd/cli/dns_proxy_test.go b/cmd/cli/dns_proxy_test.go index fdaf03d..6f5f7f0 100644 --- a/cmd/cli/dns_proxy_test.go +++ b/cmd/cli/dns_proxy_test.go @@ -170,8 +170,7 @@ func Test_prog_upstreamForWithCustomMatching(t *testing.T) { {"*.ru": []string{"upstream.1"}}, }, Matching: &ctrld.MatchingConfig{ - Order: []string{"domain", "mac", "network"}, - StopOnFirstMatch: true, + Order: []string{"domain", "mac", "network"}, }, } diff --git a/config.go b/config.go index c2d1ddf..73ffbee 100644 --- a/config.go +++ b/config.go @@ -317,8 +317,7 @@ func (lc *ListenerConfig) IsDirectDnsListener() bool { // MatchingConfig defines the configuration for rule matching behavior type MatchingConfig struct { - Order []string `mapstructure:"order" toml:"order,omitempty" json:"order" yaml:"order"` - StopOnFirstMatch bool `mapstructure:"stop_on_first_match" toml:"stop_on_first_match,omitempty" json:"stop_on_first_match" yaml:"stop_on_first_match"` + Order []string `mapstructure:"order" toml:"order,omitempty" json:"order" yaml:"order"` } // ListenerPolicyConfig specifies the policy rules for ctrld to filter incoming requests. diff --git a/internal/rulematcher/engine_test.go b/internal/rulematcher/engine_test.go index 3e1df1a..1c388dc 100644 --- a/internal/rulematcher/engine_test.go +++ b/internal/rulematcher/engine_test.go @@ -53,8 +53,7 @@ func TestMatchingEngine(t *testing.T) { { name: "Custom order - domain first", config: &MatchingConfig{ - Order: []RuleType{RuleTypeDomain, RuleTypeNetwork, RuleTypeMac}, - StopOnFirstMatch: true, + Order: []RuleType{RuleTypeDomain, RuleTypeNetwork, RuleTypeMac}, }, request: &MatchRequest{ SourceIP: net.ParseIP("192.168.0.1"), @@ -77,8 +76,7 @@ func TestMatchingEngine(t *testing.T) { { name: "Custom order - MAC first", config: &MatchingConfig{ - Order: []RuleType{RuleTypeMac, RuleTypeNetwork, RuleTypeDomain}, - StopOnFirstMatch: true, + Order: []RuleType{RuleTypeMac, RuleTypeNetwork, RuleTypeDomain}, }, request: &MatchRequest{ SourceIP: net.ParseIP("192.168.0.1"), @@ -184,7 +182,6 @@ func TestDefaultMatchingConfig(t *testing.T) { config := DefaultMatchingConfig() assert.Equal(t, []RuleType{RuleTypeNetwork, RuleTypeMac, RuleTypeDomain}, config.Order) - assert.True(t, config.StopOnFirstMatch) } func TestMatchingEngineWithInvalidRuleType(t *testing.T) { @@ -201,8 +198,7 @@ func TestMatchingEngineWithInvalidRuleType(t *testing.T) { } config := &MatchingConfig{ - Order: []RuleType{RuleType("invalid"), RuleTypeNetwork}, - StopOnFirstMatch: true, + Order: []RuleType{RuleType("invalid"), RuleTypeNetwork}, } engine := NewMatchingEngine(config) diff --git a/internal/rulematcher/types.go b/internal/rulematcher/types.go index ad43147..9e426ef 100644 --- a/internal/rulematcher/types.go +++ b/internal/rulematcher/types.go @@ -41,15 +41,13 @@ type MatchResult struct { // MatchingConfig defines the configuration for rule matching behavior type MatchingConfig struct { - Order []RuleType `json:"order" yaml:"order"` - StopOnFirstMatch bool `json:"stop_on_first_match" yaml:"stop_on_first_match"` + Order []RuleType `json:"order" yaml:"order"` } // DefaultMatchingConfig returns the default matching configuration // This maintains backward compatibility with the current behavior func DefaultMatchingConfig() *MatchingConfig { return &MatchingConfig{ - Order: []RuleType{RuleTypeNetwork, RuleTypeMac, RuleTypeDomain}, - StopOnFirstMatch: true, + Order: []RuleType{RuleTypeNetwork, RuleTypeMac, RuleTypeDomain}, } }