aboutsummaryrefslogtreecommitdiff
path: root/plugin/file/lookup.go
diff options
context:
space:
mode:
authorGravatar Kohei Yoshida <14937183+ykhr53@users.noreply.github.com> 2021-09-08 04:21:11 +0900
committerGravatar GitHub <noreply@github.com> 2021-09-07 12:21:11 -0700
commit5f6baf29734f8e5f78707989ab83f12e504f6c83 (patch)
tree7539a049e366d2cd63302da4a18f40477ab37290 /plugin/file/lookup.go
parent4b0e6a173c9abb91a2252bb8b7dfde52cf786134 (diff)
downloadcoredns-5f6baf29734f8e5f78707989ab83f12e504f6c83.tar.gz
coredns-5f6baf29734f8e5f78707989ab83f12e504f6c83.tar.zst
coredns-5f6baf29734f8e5f78707989ab83f12e504f6c83.zip
plugin/file: fix wildcard CNAME answer (#4828)
* plugin/file: fix wildcard CNAME answer Signed-off-by: Yoshida <ykhr53@yokohei.com> * plugin/file: fix synthesized CNAME answer Signed-off-by: Yoshida <ykhr53@yokohei.com>
Diffstat (limited to 'plugin/file/lookup.go')
-rw-r--r--plugin/file/lookup.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/plugin/file/lookup.go b/plugin/file/lookup.go
index 6eeb4c397..59c0927b5 100644
--- a/plugin/file/lookup.go
+++ b/plugin/file/lookup.go
@@ -115,8 +115,21 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
// Only one DNAME is allowed per name. We just pick the first one to synthesize from.
dname := dnamerrs[0]
if cname := synthesizeCNAME(state.Name(), dname.(*dns.DNAME)); cname != nil {
- ctx = context.WithValue(ctx, dnsserver.LoopKey{}, loop+1)
- answer, ns, extra, rcode := z.externalLookup(ctx, state, elem, []dns.RR{cname})
+ var (
+ answer, ns, extra []dns.RR
+ rcode Result
+ )
+
+ // We don't need to chase CNAME chain for synthesized CNAME
+ if qtype == dns.TypeCNAME {
+ answer = []dns.RR{cname}
+ ns = ap.ns(do)
+ extra = nil
+ rcode = Success
+ } else {
+ ctx = context.WithValue(ctx, dnsserver.LoopKey{}, loop+1)
+ answer, ns, extra, rcode = z.externalLookup(ctx, state, elem, []dns.RR{cname})
+ }
if do {
sigs := elem.Type(dns.TypeRRSIG)
@@ -203,7 +216,7 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
if wildElem != nil {
auth := ap.ns(do)
- if rrs := wildElem.TypeForWildcard(dns.TypeCNAME, qname); len(rrs) > 0 {
+ if rrs := wildElem.TypeForWildcard(dns.TypeCNAME, qname); len(rrs) > 0 && qtype != dns.TypeCNAME {
ctx = context.WithValue(ctx, dnsserver.LoopKey{}, loop+1)
return z.externalLookup(ctx, state, wildElem, rrs)
}