aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar ntoofu <ntoofu@users.noreply.github.com> 2021-05-04 00:48:51 +0900
committerGravatar GitHub <noreply@github.com> 2021-05-03 08:48:51 -0700
commit696c8731d65b30e2562f89b16a4b12da79eb5ae9 (patch)
tree35aab6b3e5197ab71eba96f240b4d8d5850d812c /plugin
parent32e2bd1ddd2840a9e7e857e1b9775e24086076ae (diff)
downloadcoredns-696c8731d65b30e2562f89b16a4b12da79eb5ae9.tar.gz
coredns-696c8731d65b30e2562f89b16a4b12da79eb5ae9.tar.zst
coredns-696c8731d65b30e2562f89b16a4b12da79eb5ae9.zip
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>
Diffstat (limited to 'plugin')
-rw-r--r--plugin/backend_lookup.go2
-rw-r--r--plugin/etcd/lookup_test.go17
2 files changed, 18 insertions, 1 deletions
diff --git a/plugin/backend_lookup.go b/plugin/backend_lookup.go
index 5e08efb78..b2bfa7c66 100644
--- a/plugin/backend_lookup.go
+++ b/plugin/backend_lookup.go
@@ -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
}
diff --git a/plugin/etcd/lookup_test.go b/plugin/etcd/lookup_test.go
index b1d74856a..10008ae6a 100644
--- a/plugin/etcd/lookup_test.go
+++ b/plugin/etcd/lookup_test.go
@@ -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"),
},
},
{