Skip to content

Commit 68018a9

Browse files
committed
fix(resolvers): stop search-list iteration on NODATA responses
When search domains are configured (e.g., dnsmasq `domain=le`), doggo appended search suffixes even when the original query got a valid NODATA response (NOERROR with no answers). This caused spurious `. SOA ... NXDOMAIN` results in the output. The search-list loop now also breaks when the DNS response Rcode is NOERROR (success), even if there are no answer records. NOERROR means the name exists but has no records of the requested type — that's a definitive answer, not a reason to try search suffixes. Fixes #234
1 parent 84808d4 commit 68018a9

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

pkg/resolvers/classic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (r *ClassicResolver) query(ctx context.Context, question dns.Question, flag
119119
rsp.Additional = output.Additional
120120
rsp.Edns = output.Edns
121121

122-
if len(output.Answers) > 0 {
122+
if len(output.Answers) > 0 || in.Rcode == dns.RcodeSuccess {
123123
// Stop iterating the searchlist.
124124
break
125125
}

pkg/resolvers/dnscrypt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (r *DNSCryptResolver) query(ctx context.Context, question dns.Question, fla
100100
rsp.Additional = output.Additional
101101
rsp.Edns = output.Edns
102102

103-
if len(output.Answers) > 0 {
103+
if len(output.Answers) > 0 || in.Rcode == dns.RcodeSuccess {
104104
// stop iterating the searchlist.
105105
return rsp, nil
106106
}

pkg/resolvers/doh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (r *DOHResolver) query(ctx context.Context, question dns.Question, flags Qu
135135
rsp.Additional = output.Additional
136136
rsp.Edns = output.Edns
137137

138-
if len(output.Answers) > 0 {
138+
if len(output.Answers) > 0 || msg.Rcode == dns.RcodeSuccess {
139139
// stop iterating the searchlist.
140140
break
141141
}

pkg/resolvers/doq.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (r *DOQResolver) query(ctx context.Context, question dns.Question, flags Qu
168168
rsp.Additional = output.Additional
169169
rsp.Edns = output.Edns
170170

171-
if len(output.Answers) > 0 {
171+
if len(output.Answers) > 0 || msg.Rcode == dns.RcodeSuccess {
172172
// stop iterating the searchlist.
173173
break
174174
}

0 commit comments

Comments
 (0)