Merge pull request #49 from Yannik/patch-1

return cname if requested RR was not found and cname exists (fixes #48)
This commit is contained in:
Joona Hoikkala 2018-03-13 10:42:44 +02:00 committed by GitHub
commit 978ac5d62b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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