plugin/etcd: Fix inconsistent names of glue records with TargetStrip (#4595)

* etcd plugin: Add testcases for `TargetStrip` feature

Signed-off-by: ntoofu <ntoofu@users.noreply.github.com>

* etcd plugin: Fix inconsistent names in glue records

Signed-off-by: ntoofu <ntoofu@users.noreply.github.com>
This commit is contained in:
ntoofu 2021-05-04 00:48:51 +09:00 committed by GitHub
parent 32e2bd1ddd
commit 696c8731d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -440,8 +440,8 @@ func NS(ctx context.Context, b ServiceBackend, zone string, state request.Reques
case dns.TypeA, dns.TypeAAAA: case dns.TypeA, dns.TypeAAAA:
serv.Host = msg.Domain(serv.Key) serv.Host = msg.Domain(serv.Key)
extra = append(extra, newAddress(serv, serv.Host, ip, what))
ns := serv.NewNS(state.QName()) ns := serv.NewNS(state.QName())
extra = append(extra, newAddress(serv, ns.Ns, ip, what))
if _, ok := seen[ns.Ns]; ok { if _, ok := seen[ns.Ns]; ok {
continue continue
} }

View file

@ -37,12 +37,16 @@ var services = []*msg.Service{
{Host: "sub.server1", Port: 0, Key: "a.sub.region1.skydns.test."}, {Host: "sub.server1", Port: 0, Key: "a.sub.region1.skydns.test."},
{Host: "sub.server2", Port: 80, Key: "b.sub.region1.skydns.test."}, {Host: "sub.server2", Port: 80, Key: "b.sub.region1.skydns.test."},
{Host: "10.0.0.1", Port: 8080, Key: "c.sub.region1.skydns.test."}, {Host: "10.0.0.1", Port: 8080, Key: "c.sub.region1.skydns.test."},
// TargetStrip.
{Host: "10.0.0.1", Port: 8080, Key: "a.targetstrip.skydns.test.", TargetStrip: 1},
// Cname loop. // Cname loop.
{Host: "a.cname.skydns.test", Key: "b.cname.skydns.test."}, {Host: "a.cname.skydns.test", Key: "b.cname.skydns.test."},
{Host: "b.cname.skydns.test", Key: "a.cname.skydns.test."}, {Host: "b.cname.skydns.test", Key: "a.cname.skydns.test."},
// Nameservers. // Nameservers.
{Host: "10.0.0.2", Key: "a.ns.dns.skydns.test."}, {Host: "10.0.0.2", Key: "a.ns.dns.skydns.test."},
{Host: "10.0.0.3", Key: "b.ns.dns.skydns.test."}, {Host: "10.0.0.3", Key: "b.ns.dns.skydns.test."},
{Host: "10.0.0.4", Key: "ns1.c.ns.dns.skydns.test.", TargetStrip: 1},
{Host: "10.0.0.5", Key: "ns2.c.ns.dns.skydns.test.", TargetStrip: 1},
// Zone name as A record (basic, return all) // Zone name as A record (basic, return all)
{Host: "10.0.0.2", Key: "x.skydns_zonea.test."}, {Host: "10.0.0.2", Key: "x.skydns_zonea.test."},
{Host: "10.0.0.3", Key: "y.skydns_zonea.test."}, {Host: "10.0.0.3", Key: "y.skydns_zonea.test."},
@ -124,6 +128,14 @@ var dnsTestCases = []test.Case{
}, },
Extra: []dns.RR{test.A("c.sub.region1.skydns.test. 300 IN A 10.0.0.1")}, Extra: []dns.RR{test.A("c.sub.region1.skydns.test. 300 IN A 10.0.0.1")},
}, },
// SRV TargetStrip Test
{
Qname: "targetstrip.skydns.test.", Qtype: dns.TypeSRV,
Answer: []dns.RR{
test.SRV("targetstrip.skydns.test. 300 IN SRV 10 100 8080 targetstrip.skydns.test."),
},
Extra: []dns.RR{test.A("targetstrip.skydns.test. 300 IN A 10.0.0.1")},
},
// CNAME (unresolvable internal name) // CNAME (unresolvable internal name)
{ {
Qname: "cname.prod.region1.skydns.test.", Qtype: dns.TypeA, Qname: "cname.prod.region1.skydns.test.", Qtype: dns.TypeA,
@ -217,10 +229,13 @@ var dnsTestCases = []test.Case{
Answer: []dns.RR{ Answer: []dns.RR{
test.NS("skydns.test. 300 NS a.ns.dns.skydns.test."), test.NS("skydns.test. 300 NS a.ns.dns.skydns.test."),
test.NS("skydns.test. 300 NS b.ns.dns.skydns.test."), test.NS("skydns.test. 300 NS b.ns.dns.skydns.test."),
test.NS("skydns.test. 300 NS c.ns.dns.skydns.test."),
}, },
Extra: []dns.RR{ Extra: []dns.RR{
test.A("a.ns.dns.skydns.test. 300 A 10.0.0.2"), test.A("a.ns.dns.skydns.test. 300 A 10.0.0.2"),
test.A("b.ns.dns.skydns.test. 300 A 10.0.0.3"), test.A("b.ns.dns.skydns.test. 300 A 10.0.0.3"),
test.A("c.ns.dns.skydns.test. 300 A 10.0.0.4"),
test.A("c.ns.dns.skydns.test. 300 A 10.0.0.5"),
}, },
}, },
// NS Record Test // NS Record Test
@ -234,6 +249,8 @@ var dnsTestCases = []test.Case{
Answer: []dns.RR{ Answer: []dns.RR{
test.A("ns.dns.skydns.test. 300 A 10.0.0.2"), test.A("ns.dns.skydns.test. 300 A 10.0.0.2"),
test.A("ns.dns.skydns.test. 300 A 10.0.0.3"), test.A("ns.dns.skydns.test. 300 A 10.0.0.3"),
test.A("ns.dns.skydns.test. 300 A 10.0.0.4"),
test.A("ns.dns.skydns.test. 300 A 10.0.0.5"),
}, },
}, },
{ {