mirror of
https://github.com/coredns/coredns.git
synced 2025-11-22 20:02:18 -05:00
plugin/template: fix CNAME upstream handling (#1886)
This commit is contained in:
@@ -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...)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user