Skip to content

Commit

Permalink
Pull request: dnsforward: fix nxdomain for internal aaaa reqs
Browse files Browse the repository at this point in the history
Updates AdguardTeam#2393.

Squashed commit of the following:

commit 5ea4d3c
Author: Ainar Garipov <[email protected]>
Date:   Thu Mar 25 17:01:08 2021 +0300

    dnsforward: fix nxdomain for internal aaaa reqs
  • Loading branch information
ainar-g committed Mar 25, 2021
1 parent 88d9246 commit 3764c1d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/dnsforward/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ func (s *Server) onDHCPLeaseChanged(flags int) {
func (s *Server) processInternalHosts(dctx *dnsContext) (rc resultCode) {
req := dctx.proxyCtx.Req
q := req.Question[0]
if q.Qtype != dns.TypeA {

// Go on processing the AAAA request despite the fact that we don't
// support it yet. The expected behavior here is to respond with an
// empty asnwer and not NXDOMAIN.
if q.Qtype != dns.TypeA && q.Qtype != dns.TypeAAAA {
return resultCodeSuccess
}

Expand Down
17 changes: 16 additions & 1 deletion internal/dnsforward/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func TestServer_ProcessInternalHosts(t *testing.T) {
wantIP: nil,
qtyp: dns.TypeA,
wantRes: resultCodeSuccess,
}, {
name: "success_internal_aaaa",
host: "example.lan",
suffix: defaultAutohostSuffix,
wantErrMsg: "",
wantIP: nil,
qtyp: dns.TypeAAAA,
wantRes: resultCodeSuccess,
}}

for _, tc := range testCases {
Expand Down Expand Up @@ -92,7 +100,14 @@ func TestServer_ProcessInternalHosts(t *testing.T) {
}

pctx := dctx.proxyCtx
if tc.wantIP == nil {
if tc.qtyp == dns.TypeAAAA {
// TODO(a.garipov): Remove this special handling
// when we fully support AAAA.
require.NotNil(t, pctx.Res)

ans := pctx.Res.Answer
require.Len(t, ans, 0)
} else if tc.wantIP == nil {
assert.Nil(t, pctx.Res)
} else {
require.NotNil(t, pctx.Res)
Expand Down

0 comments on commit 3764c1d

Please sign in to comment.