Skip to content

Commit 02bd17a

Browse files
committed
dnsx/resolver: send original prefs in onUpstreamAnswer
1 parent d2c4f6f commit 02bd17a

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

intra/backend/dnsx_listener.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ type DNSOpts struct {
8888
NOBLOCK bool
8989
}
9090

91+
func (o *DNSOpts) Copy() *DNSOpts {
92+
if o == nil {
93+
return nil
94+
}
95+
return &DNSOpts{
96+
UID: o.UID,
97+
PIDCSV: o.PIDCSV,
98+
IPCSV: o.IPCSV,
99+
TIDCSV: o.TIDCSV,
100+
TIDSECCSV: o.TIDSECCSV,
101+
NOBLOCK: o.NOBLOCK,
102+
}
103+
}
104+
91105
// String implements fmt.Stringer.
92106
func (s *DNSSummary) String() string {
93107
if s == nil {
@@ -107,7 +121,7 @@ type DNSListener interface {
107121
// The listener may return DNSOpts to specify if another upstream should override that answer.
108122
// Another round of OnQuery is NOT called in this case, and OnResponse is called once after processing
109123
// DNSOpts returned by OnUpstreamAnswer if it has a non-empty TIDCSV (overriding the original TIDCSV).
110-
OnUpstreamAnswer(smm *DNSSummary, unmodifiedipcsv string) *DNSOpts
124+
OnUpstreamAnswer(smm *DNSSummary, forPref *DNSOpts, unmodifiedipcsv string) *DNSOpts
111125
// OnResponse is called when a DNS response is received. May be called twice for the same query,
112126
// for instance, when different options are requested through OnUpstreamAnswer.
113127
OnResponse(*DNSSummary)

intra/dnsx/transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ runagain:
720720

721721
if run == 1 {
722722
pref2, ouacompleted := core.Grx("r.onUA."+qname, func(_ context.Context) (*x.DNSOpts, error) {
723-
return r.listener.OnUpstreamAnswer(smm, realips), nil
723+
return r.listener.OnUpstreamAnswer(smm, pref.Copy(), realips), nil
724724
}, listenerTimeout)
725725
if !ouacompleted {
726726
log.W("dns: fwd: for %s[%s]; preferences2 missing for %s:%d; ips? %s", smm.ID, uid, qname, qtyp, realips)

0 commit comments

Comments
 (0)