return cname if requested RR was not found and cname exists

This commit is contained in:
Yannik Sembritzki 2018-03-02 14:58:39 +01:00
parent 9a908d7d6b
commit 4d214d7f52

6
dns.go
View File

@ -52,7 +52,11 @@ func answer(q dns.Question) ([]dns.RR, int, error) {
var rtype = q.Qtype
r, ok := RR.Records[rtype][domain]
if !ok {
rcode = dns.RcodeNameError
r, ok = RR.Records[dns.TypeCNAME][domain]
if !ok {
rcode = dns.RcodeNameError
}
}
log.WithFields(log.Fields{"qtype": dns.TypeToString[rtype], "domain": domain, "rcode": dns.RcodeToString[rcode]}).Debug("Answering question for domain")
return r, rcode, nil