Skip to content

Commit

Permalink
sendDNSQuery() log udp and tcp query results
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronelliott committed Jun 16, 2021
1 parent c56356e commit 78cb445
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dnsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package main
import (
"errors"
"fmt"
"log"
"net"
"strings"
"sync"
Expand Down Expand Up @@ -154,9 +155,11 @@ func sendDNSQuery(m *dns.Msg, ns string) (*dns.Msg, error) {
// truncation and timeout; see https://github.com/caddyserver/caddy/issues/3639
truncated := in != nil && in.Truncated
timeoutErr := err != nil && strings.Contains(err.Error(), "timeout")
if truncated || timeoutErr {
log.Printf("udp sendDNSQuery result ns:%v tout:%v trunc:%v err:%v",ns,timeoutErr,truncated,err)
if truncated || timeoutErr {
tcp := &dns.Client{Net: "tcp", Timeout: dnsTimeout}
in, _, err = tcp.Exchange(m, ns)
log.Printf("tcp sendDNSQuery result ns:%v err:%v",ns,err)
}
return in, err
}
Expand Down

0 comments on commit 78cb445

Please sign in to comment.