Skip to content

Commit

Permalink
Act based on RFC and return NOERROR and nodata
Browse files Browse the repository at this point in the history
https://tools.ietf.org/html/rfc4074#section-3 suggests we have to
return NOERROR status and NODATA (empty reply)

Signed-off-by: Dinar Valeev <dinar.valeev@absa.africa>
k0da committed Apr 6, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 510e17d commit 5d39446
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/coredns/values.yaml
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ coredns:
- name: forward
parameters: . /etc/resolv.conf
- name: k8s_crd
parameters: .
parameters: example.org
configBlock: |-
resources DNSEndpoint
apex dns1
3 changes: 0 additions & 3 deletions gateway.go
Original file line number Diff line number Diff line change
@@ -162,9 +162,6 @@ func (gw *Gateway) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
switch state.QType() {
case dns.TypeA:
m.Answer = gw.A(state, addrs, ttl)
case dns.TypeAAAA:
m.Ns = []dns.RR{gw.soa(state)}
m.Rcode = dns.RcodeNameError
default:
m.Ns = []dns.RR{gw.soa(state)}
}
9 changes: 8 additions & 1 deletion terratest/test/basic_test.go
Original file line number Diff line number Diff line change
@@ -107,9 +107,16 @@ func TestBasicExample(t *testing.T) {
assert.Equal(t, uint32(123), msg.Answer[0].(*dns.A).Hdr.Ttl)
})

t.Run("Type AAAA returns Rcode 3", func(t *testing.T) {
t.Run("Type AAAA returns Rcode 0", func(t *testing.T) {
msg, err := DigMsg(t, "localhost", 1053, "host1.example.org", dns.TypeAAAA)
require.NoError(t, err)
assert.Equal(t, dns.RcodeSuccess, msg.Rcode)
assert.Equal(t, 0, len(msg.Answer))
})
t.Run("Type AAAA returns Rcode 3 for non existing host", func(t *testing.T) {
msg, err := DigMsg(t, "localhost", 1053, "nonexistent.example.org", dns.TypeAAAA)
require.NoError(t, err)
assert.Equal(t, dns.RcodeNameError, msg.Rcode)
assert.Equal(t, 0, len(msg.Answer))
})
}

0 comments on commit 5d39446

Please sign in to comment.