diff options
Diffstat (limited to 'plugin/file/lookup.go')
-rw-r--r-- | plugin/file/lookup.go | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/plugin/file/lookup.go b/plugin/file/lookup.go index 28da3d4d0..e036d809a 100644 --- a/plugin/file/lookup.go +++ b/plugin/file/lookup.go @@ -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 + } + 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 + return m.Answer, Success } // additionalProcessing checks the current answer section and retrieves A or AAAA records |