diff options
author | 2017-03-02 19:35:44 +0000 | |
---|---|---|
committer | 2017-03-02 19:35:44 +0000 | |
commit | 6966bce653a1a866c2a8fc3f8b5bcccf123a046d (patch) | |
tree | 6e5e0090f19cdf33996579a494e24147e5c46df1 /middleware/proxy/proxy.go | |
parent | a3f7788686a3833677b5c86da90d70604637d307 (diff) | |
download | coredns-6966bce653a1a866c2a8fc3f8b5bcccf123a046d.tar.gz coredns-6966bce653a1a866c2a8fc3f8b5bcccf123a046d.tar.zst coredns-6966bce653a1a866c2a8fc3f8b5bcccf123a046d.zip |
Fix resolving CNAME with no proxy (#564)
This fixes a crash when we resolve (or try to) an external CNAME
when no proxy is set.
Add test as well.
Diffstat (limited to 'middleware/proxy/proxy.go')
-rw-r--r-- | middleware/proxy/proxy.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go index 9457fb2a1..d21dee732 100644 --- a/middleware/proxy/proxy.go +++ b/middleware/proxy/proxy.go @@ -142,6 +142,10 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( } func (p Proxy) match(state request.Request) (u Upstream) { + if p.Upstreams == nil { + return nil + } + longestMatch := 0 for _, upstream := range *p.Upstreams { from := upstream.From() |