Fix DNS match log

This commit is contained in:
世界 2024-12-15 21:27:39 +08:00
parent dda692e955
commit 5952c174f7
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -45,20 +45,22 @@ func (r *Router) matchDNS(ctx context.Context, allowFakeIP bool, ruleIndex int,
panic("no context") panic("no context")
} }
var options dns.QueryOptions var options dns.QueryOptions
if ruleIndex < len(r.dnsRules) { var (
dnsRules := r.dnsRules currentRuleIndex int
currentRule adapter.DNSRule
)
if ruleIndex != -1 { if ruleIndex != -1 {
dnsRules = dnsRules[ruleIndex+1:] currentRuleIndex = ruleIndex + 1
} }
for currentRuleIndex, currentRule := range dnsRules { for currentRuleIndex, currentRule = range r.dnsRules[currentRuleIndex:] {
if currentRule.WithAddressLimit() && !isAddressQuery { if currentRule.WithAddressLimit() && !isAddressQuery {
continue continue
} }
metadata.ResetRuleCache() metadata.ResetRuleCache()
if currentRule.Match(metadata) { if currentRule.Match(metadata) {
displayRuleIndex := currentRuleIndex displayRuleIndex := currentRuleIndex
if displayRuleIndex != -1 { if ruleIndex != -1 {
displayRuleIndex += displayRuleIndex + 1 displayRuleIndex += ruleIndex + 1
} }
ruleDescription := currentRule.String() ruleDescription := currentRule.String()
if ruleDescription != "" { if ruleDescription != "" {
@ -110,7 +112,6 @@ func (r *Router) matchDNS(ctx context.Context, allowFakeIP bool, ruleIndex int,
} }
} }
} }
}
if domainStrategy, dsLoaded := r.transportDomainStrategy[r.defaultTransport]; dsLoaded { if domainStrategy, dsLoaded := r.transportDomainStrategy[r.defaultTransport]; dsLoaded {
options.Strategy = domainStrategy options.Strategy = domainStrategy
} else { } else {