log output upstream dns server reply code

nghttp2
fangdingjun 9 years ago
parent a86b993931
commit a72bd45423

@ -105,41 +105,50 @@ func handleRoot(w dns.ResponseWriter, r *dns.Msg) {
done = 0 done = 0
for _, sv := range Servers { for _, sv := range Servers {
if sv.match(domain) { if sv.match(domain) {
logger.Debug("%s query %s %s %s, forward to %s:%s\n",
res, err = sv.query(r)
if err != nil {
logger.Error("%s", err)
continue
}
logger.Debug("%s query %s %s %s, forward to %s:%s, %s\n",
w.RemoteAddr(), w.RemoteAddr(),
domain, domain,
dns.ClassToString[r.Question[0].Qclass], dns.ClassToString[r.Question[0].Qclass],
dns.TypeToString[r.Question[0].Qtype], dns.TypeToString[r.Question[0].Qtype],
sv.Proto, sv.Addr) sv.Proto, sv.Addr,
res, err = sv.query(r) dns.RcodeToString[res.Rcode],
if err == nil { )
if !in_blacklist(res) && res.Rcode != dns.RcodeServerFailure {
if res.Rcode != dns.RcodeServerFailure && !in_blacklist(res) {
w.WriteMsg(res) w.WriteMsg(res)
done = 1 done = 1
break break
} }
} else {
logger.Error("%s", err)
}
} }
} }
if done != 1 { if done != 1 {
res, err = DefaultServer.query(r) res, err = DefaultServer.query(r)
logger.Debug("%s query %s %s %s, use default server %s:%s\n", if err != nil {
logger.Error("%s", err)
continue
}
logger.Debug("%s query %s %s %s, use default server %s:%s, %s\n",
w.RemoteAddr(), w.RemoteAddr(),
domain, domain,
dns.ClassToString[r.Question[0].Qclass], dns.ClassToString[r.Question[0].Qclass],
dns.TypeToString[r.Question[0].Qtype], dns.TypeToString[r.Question[0].Qtype],
DefaultServer.Proto, DefaultServer.Addr) DefaultServer.Proto, DefaultServer.Addr,
if err == nil { dns.RcodeToString[res.Rcode],
if !in_blacklist(res) && res.Rcode != dns.RcodeServerFailure { )
if res.Rcode != dns.RcodeServerFailure && !in_blacklist(res) {
w.WriteMsg(res) w.WriteMsg(res)
done = 1 done = 1
} }
} else {
logger.Error("%s", err)
}
} }
if done == 1 { if done == 1 {

Loading…
Cancel
Save