plugin/template: fix CNAME upstream handling (#1886)

This commit is contained in:
Chris O'Haver
2018-06-21 14:38:29 -04:00
committed by GitHub
parent ad8021230c
commit 716791aa09
4 changed files with 97 additions and 4 deletions

View File

@@ -34,7 +34,7 @@ type template struct {
qclass uint16
qtype uint16
fall fall.F
upstream upstream.Upstream
upstream *upstream.Upstream
}
type templateData struct {
@@ -84,8 +84,8 @@ func (h Handler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
return dns.RcodeServerFailure, err
}
msg.Answer = append(msg.Answer, rr)
if rr.Header().Rrtype == dns.TypeCNAME {
up, _ := template.upstream.Lookup(state, rr.(*dns.CNAME).Target, dns.TypeA)
if template.upstream != nil && (state.QType() == dns.TypeA || state.QType() == dns.TypeAAAA) && rr.Header().Rrtype == dns.TypeCNAME {
up, _ := template.upstream.Lookup(state, rr.(*dns.CNAME).Target, state.QType())
msg.Answer = append(msg.Answer, up.Answer...)
}
}