Skip to content

Instantly share code, notes, and snippets.

@slackpad
Created December 19, 2016 22:59
Show Gist options
  • Save slackpad/9547780dbb4846bd87276c602958d173 to your computer and use it in GitHub Desktop.
Save slackpad/9547780dbb4846bd87276c602958d173 to your computer and use it in GitHub Desktop.
Simple patch to add extra TRACE level logging for failed requests
diff --git a/command/agent/dns.go b/command/agent/dns.go
index 7f373cd4..9fa78b66 100644
--- a/command/agent/dns.go
+++ b/command/agent/dns.go
@@ -270,6 +270,9 @@ func (d *DNSServer) handleQuery(resp dns.ResponseWriter, req *dns.Msg) {
if err := resp.WriteMsg(m); err != nil {
d.logger.Printf("[WARN] dns: failed to respond: %v", err)
}
+ if m.MsgHdr.Rcode != 0 {
+ d.logger.Printf("[TRACE] dns: request for %v failed: rcode=%s", q, dns.RcodeToString[m.MsgHdr.Rcode])
+ }
}
// addSOA is used to add an SOA record to a message for the given domain
@@ -939,6 +942,9 @@ func (d *DNSServer) handleRecurse(resp dns.ResponseWriter, req *dns.Msg) {
if err := resp.WriteMsg(r); err != nil {
d.logger.Printf("[WARN] dns: failed to respond: %v", err)
}
+ if r.MsgHdr.Rcode != 0 {
+ d.logger.Printf("[TRACE] dns: request for %v failed: rcode=%s", q, dns.RcodeToString[r.MsgHdr.Rcode])
+ }
return
}
d.logger.Printf("[ERR] dns: recurse failed: %v", err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment