Commit 696c8731 authored by ntoofu's avatar ntoofu Committed by GitHub

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

* etcd plugin: Add testcases for `TargetStrip` feature
Signed-off-by: default avatarntoofu <ntoofu@users.noreply.github.com>

* etcd plugin: Fix inconsistent names in glue records
Signed-off-by: default avatarntoofu <ntoofu@users.noreply.github.com>
parent 32e2bd1d
......@@ -440,8 +440,8 @@ func NS(ctx context.Context, b ServiceBackend, zone string, state request.Reques
case dns.TypeA, dns.TypeAAAA:
serv.Host = msg.Domain(serv.Key)
extra = append(extra, newAddress(serv, serv.Host, ip, what))
ns := serv.NewNS(state.QName())
extra = append(extra, newAddress(serv, ns.Ns, ip, what))
if _, ok := seen[ns.Ns]; ok {
continue
}
......
......@@ -37,12 +37,16 @@ var services = []*msg.Service{
{Host: "sub.server1", Port: 0, Key: "a.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."},
// TargetStrip.
{Host: "10.0.0.1", Port: 8080, Key: "a.targetstrip.skydns.test.", TargetStrip: 1},
// Cname loop.
{Host: "a.cname.skydns.test", Key: "b.cname.skydns.test."},
{Host: "b.cname.skydns.test", Key: "a.cname.skydns.test."},
// Nameservers.
{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.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)
{Host: "10.0.0.2", Key: "x.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")},
},
// 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)
{
Qname: "cname.prod.region1.skydns.test.", Qtype: dns.TypeA,
......@@ -217,10 +229,13 @@ var dnsTestCases = []test.Case{
Answer: []dns.RR{
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 c.ns.dns.skydns.test."),
},
Extra: []dns.RR{
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("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
......@@ -234,6 +249,8 @@ var dnsTestCases = []test.Case{
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.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"),
},
},
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment