fix: return SOA and NS records when queried for a record CNAMEd to origin (#7808)

* fix: return SOA and NS records when queried for a record CNAMEd to origin

Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>

* chore(test): add test for covering cname to origin scenario in file plugin

Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>

---------

Signed-off-by: Shiv Tyagi <shivtyagi3015@gmail.com>
This commit is contained in:
Shiv Tyagi
2026-01-22 08:05:48 +05:30
committed by GitHub
parent 1c9575747f
commit f1f0955cb9
3 changed files with 64 additions and 2 deletions

View File

@@ -331,7 +331,7 @@ func (z *Zone) externalLookup(ctx context.Context, state request.Request, elem *
targetName := rrs[0].(*dns.CNAME).Target
elem, _ = z.Search(targetName)
if elem == nil {
if elem == nil || (qtype == dns.TypeNS || qtype == dns.TypeSOA && targetName == z.origin) {
lookupRRs, result := z.doLookup(ctx, state, targetName, qtype)
rrs = append(rrs, lookupRRs...)
return rrs, z.ns(do), nil, result
@@ -351,7 +351,7 @@ Redo:
}
targetName := cname[0].(*dns.CNAME).Target
elem, _ = z.Search(targetName)
if elem == nil {
if elem == nil || (qtype == dns.TypeNS || qtype == dns.TypeSOA && targetName == z.origin) {
lookupRRs, result := z.doLookup(ctx, state, targetName, qtype)
rrs = append(rrs, lookupRRs...)
return rrs, z.ns(do), nil, result