From f46df03695048f949849a031d853a969d3330093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 13 Mar 2025 19:52:50 +0800 Subject: [PATCH] Fix DNS lookup context pollution --- dns/router.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dns/router.go b/dns/router.go index cdff388e..bd4eb3f1 100644 --- a/dns/router.go +++ b/dns/router.go @@ -383,7 +383,8 @@ func (r *Router) Lookup(ctx context.Context, domain string, options adapter.DNSQ ruleIndex = -1 for { dnsCtx := adapter.OverrideContext(ctx) - transport, rule, ruleIndex = r.matchDNS(ctx, false, ruleIndex, true, &options) + dnsOptions := options + transport, rule, ruleIndex = r.matchDNS(ctx, false, ruleIndex, true, &dnsOptions) if rule != nil { switch action := rule.Action().(type) { case *R.RuleActionReject: @@ -416,10 +417,10 @@ func (r *Router) Lookup(ctx context.Context, domain string, options adapter.DNSQ return rule.MatchAddressLimit(metadata) } } - if options.Strategy == C.DomainStrategyAsIS { - options.Strategy = r.defaultDomainStrategy + if dnsOptions.Strategy == C.DomainStrategyAsIS { + dnsOptions.Strategy = r.defaultDomainStrategy } - responseAddrs, err = r.client.Lookup(dnsCtx, transport, domain, options, responseCheck) + responseAddrs, err = r.client.Lookup(dnsCtx, transport, domain, dnsOptions, responseCheck) if responseCheck == nil || err == nil { break }