CNAMEs targets should be in answer section.

A target of a cname must be put in the answer section. Fix this and add
a AAAA test for quad-AAAA CNAME responses.

Fixes #125
This commit is contained in:
Miek Gieben
2016-04-16 17:55:11 +01:00
parent dfe5cae114
commit 4e3c82bec5
3 changed files with 12 additions and 12 deletions

View File

@@ -16,7 +16,6 @@ var dnssecTestCases = []test.Case{
{
Qname: "miek.nl.", Qtype: dns.TypeSOA, Do: true,
Answer: []dns.RR{
// because we sort, this look fishy, but it is OK.
test.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="),
test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"),
},
@@ -45,13 +44,13 @@ var dnssecTestCases = []test.Case{
{
Qname: "www.miek.nl.", Qtype: dns.TypeA, Do: true,
Answer: []dns.RR{
test.A("a.miek.nl. 1800 IN A 139.162.196.78"),
test.RRSIG("a.miek.nl. 1800 IN RRSIG A 8 3 1800 20160426031301 20160327031301 12051 miek.nl. lxLotCjWZ3kihTxk="),
test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."),
},
Extra: []dns.RR{
test.OPT(4096, true),
test.A("a.miek.nl. 1800 IN A 139.162.196.78"),
test.RRSIG("a.miek.nl. 1800 IN RRSIG A 8 3 1800 20160426031301 20160327031301 12051 miek.nl. lxLotCjWZ3kihTxk="),
},
},
{

View File

@@ -151,15 +151,15 @@ func (z *Zone) lookupCNAME(rrs []dns.RR, qtype uint16, do bool) ([]dns.RR, []dns
if elem == nil {
return rrs, nil, nil, Success
}
extra := cnameForType(elem.All(), qtype)
targets := cnameForType(elem.All(), qtype)
if do {
sigs := elem.Types(dns.TypeRRSIG)
sigs = signatureForSubType(sigs, qtype)
if len(sigs) > 0 {
extra = append(extra, sigs...)
targets = append(targets, sigs...)
}
}
return rrs, nil, extra, Success
return append(rrs, targets...), nil, nil, Success
}
func cnameForType(targets []dns.RR, origQtype uint16) []dns.RR {

View File

@@ -16,11 +16,15 @@ var dnsTestCases = []test.Case{
{
Qname: "www.miek.nl.", Qtype: dns.TypeA,
Answer: []dns.RR{
test.A("a.miek.nl. 1800 IN A 139.162.196.78"),
test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."),
},
Extra: []dns.RR{
test.A("a.miek.nl. 1800 IN A 139.162.196.78"),
},
{
Qname: "www.miek.nl.", Qtype: dns.TypeAAAA,
Answer: []dns.RR{
test.AAAA("a.miek.nl. 1800 IN AAAA 2a01:7e00::f03c:91ff:fef1:6735"),
test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."),
},
},
{
@@ -136,9 +140,6 @@ func BenchmarkLookup(b *testing.B) {
Qname: "www.miek.nl.", Qtype: dns.TypeA,
Answer: []dns.RR{
test.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."),
},
Extra: []dns.RR{
test.A("a.miek.nl. 1800 IN A 139.162.196.78"),
},
}