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.
This commit is contained in:
Miek Gieben 2017-03-02 19:35:44 +00:00 committed by GitHub
parent a3f7788686
commit 6966bce653
11 changed files with 67 additions and 9 deletions

View file

@ -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()