plugin/file: return SOA in authority for negative CNAME target answers (#8226)

This commit is contained in:
Saleh
2026-07-05 10:39:15 +03:00
committed by GitHub
parent ea19f815a6
commit 31559f43e8
2 changed files with 70 additions and 2 deletions

View File

@@ -315,6 +315,16 @@ func (a Apex) ns(do bool) []dns.RR {
return a.NS
}
// authority returns the records for the authority section of a response with
// the given result: the SOA for negative answers (NXDOMAIN/NODATA), as
// required by RFC 2308, and the NS records otherwise.
func (z *Zone) authority(do bool, result Result) []dns.RR {
if result == NameError || result == NoData {
return z.soa(do)
}
return z.ns(do)
}
// externalLookup adds signatures and tries to resolve CNAMEs that point to external names.
func (z *Zone) externalLookup(ctx context.Context, state request.Request, elem *tree.Elem, rrs []dns.RR) ([]dns.RR, []dns.RR, []dns.RR, Result) {
qtype := state.QType()
@@ -331,7 +341,7 @@ func (z *Zone) externalLookup(ctx context.Context, state request.Request, elem *
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
return rrs, z.authority(do, result), nil, result
}
i := 0
@@ -351,7 +361,7 @@ Redo:
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
return rrs, z.authority(do, result), nil, result
}
i++