Skip to content

Commit

Permalink
Streamlined debug output a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
mreiger committed Aug 7, 2024
1 parent ec6cdfc commit 4fb4d3d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/dns/dns_proxy_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ func (h *DNSProxyHandler) ServeDNS(w dnsgo.ResponseWriter, request *dnsgo.Msg) {
}
}()

scopedLog.Info("started processing request")
serverAddress := w.LocalAddr()
bufsize := getBufSize(serverAddress.Network(), request)
scopedLog.Info("request info", "server", serverAddress, "bufsize", bufsize, "request", request)
scopedLog.Info("started processing request", "server", serverAddress, "bufsize", bufsize, "request", request)

response, err := h.getDataFromDNS(serverAddress, request)
if err != nil {
Expand All @@ -69,7 +68,6 @@ func (h *DNSProxyHandler) ServeDNS(w dnsgo.ResponseWriter, request *dnsgo.Msg) {
return
}

scopedLog.Info("truncating response before sending reply to client", "bufsize", bufsize)
originalResponse := response.Copy()
/*
Why are we truncating the answer?
Expand All @@ -78,7 +76,7 @@ func (h *DNSProxyHandler) ServeDNS(w dnsgo.ResponseWriter, request *dnsgo.Msg) {
Therefore we find out the buffer size of the client from the request (with UDP it's 512 bytes by default) and limit the reply to this buffer size before we send it out. The Truncate method will try compression first to fit the message into the buffer size and will truncate the message if necessary.
*/
response.Truncate(bufsize)
scopedLog.Info("original response and processed reply", "original response", originalResponse, "response to client", response)
scopedLog.Info("processing response", "buffer size", bufsize, "original response", originalResponse, "truncated response", response)

go h.updateCache(time.Now(), response)

Expand Down

0 comments on commit 4fb4d3d

Please sign in to comment.