mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 18:53:43 -04:00
plugin/file: Use NXDOMAIN response if CNAME target is NXDOMAIN (#4303)
* pass through nxdomain results Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * return srvfail and nodata results Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add test Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * cover more response cases Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -307,8 +307,9 @@ func (z *Zone) externalLookup(ctx context.Context, state request.Request, elem *
|
||||
targetName := rrs[0].(*dns.CNAME).Target
|
||||
elem, _ = z.Tree.Search(targetName)
|
||||
if elem == nil {
|
||||
rrs = append(rrs, z.doLookup(ctx, state, targetName, qtype)...)
|
||||
return rrs, z.Apex.ns(do), nil, Success
|
||||
lookupRRs, result := z.doLookup(ctx, state, targetName, qtype)
|
||||
rrs = append(rrs, lookupRRs...)
|
||||
return rrs, z.Apex.ns(do), nil, result
|
||||
}
|
||||
|
||||
i := 0
|
||||
@@ -326,8 +327,9 @@ Redo:
|
||||
targetName := cname[0].(*dns.CNAME).Target
|
||||
elem, _ = z.Tree.Search(targetName)
|
||||
if elem == nil {
|
||||
rrs = append(rrs, z.doLookup(ctx, state, targetName, qtype)...)
|
||||
return rrs, z.Apex.ns(do), nil, Success
|
||||
lookupRRs, result := z.doLookup(ctx, state, targetName, qtype)
|
||||
rrs = append(rrs, lookupRRs...)
|
||||
return rrs, z.Apex.ns(do), nil, result
|
||||
}
|
||||
|
||||
i++
|
||||
@@ -352,15 +354,24 @@ Redo:
|
||||
return rrs, z.Apex.ns(do), nil, Success
|
||||
}
|
||||
|
||||
func (z *Zone) doLookup(ctx context.Context, state request.Request, target string, qtype uint16) []dns.RR {
|
||||
func (z *Zone) doLookup(ctx context.Context, state request.Request, target string, qtype uint16) ([]dns.RR, Result) {
|
||||
m, e := z.Upstream.Lookup(ctx, state, target, qtype)
|
||||
if e != nil {
|
||||
return nil
|
||||
return nil, Success
|
||||
}
|
||||
if m == nil {
|
||||
return nil
|
||||
return nil, Success
|
||||
}
|
||||
return m.Answer
|
||||
if m.Rcode == dns.RcodeNameError {
|
||||
return m.Answer, NameError
|
||||
}
|
||||
if m.Rcode == dns.RcodeServerFailure {
|
||||
return m.Answer, ServerFailure
|
||||
}
|
||||
if m.Rcode == dns.RcodeSuccess && len(m.Answer) == 0 {
|
||||
return m.Answer, NoData
|
||||
}
|
||||
return m.Answer, Success
|
||||
}
|
||||
|
||||
// additionalProcessing checks the current answer section and retrieves A or AAAA records
|
||||
|
||||
Reference in New Issue
Block a user