diff --git a/server.go b/server.go index d147ca1..ab64711 100644 --- a/server.go +++ b/server.go @@ -39,7 +39,7 @@ func (srv *server) serveUDP() { udpconn, err := net.ListenUDP("udp", &net.UDPAddr{IP: _ip, Port: _port}) if err != nil { - log.Fatalf("listen udp error", err) + log.Fatalf("listen udp error %s", err) } defer udpconn.Close() diff --git a/server_https.go b/server_https.go index 8f14cfa..8a6d001 100644 --- a/server_https.go +++ b/server_https.go @@ -52,10 +52,15 @@ func (srv *server) handleHTTP2Req(w http.ResponseWriter, r *http.Request) { } reply := false for _, up := range srv.upstreams { + log.Debugf("from %s query upstream %s", r.RemoteAddr, up.String()) + log.Debugln("query", msg.Question[0].String()) m, err := queryUpstream(msg, up) if err == nil { w.Header().Set("content-type", "application/dns-message") w.WriteHeader(http.StatusOK) + for _, a := range m.Answer { + log.Debugln("result", a.String()) + } d, _ := m.Pack() w.Write(d) reply = true diff --git a/server_tcp.go b/server_tcp.go index 92317a1..dce483b 100644 --- a/server_tcp.go +++ b/server_tcp.go @@ -19,8 +19,13 @@ func (srv *server) handleTCP(c net.Conn) { } reply := false for _, up := range srv.upstreams { + log.Debugf("from %s query upstream %s", conn.RemoteAddr(), up.String()) + log.Debugln("query", msg.Question[0].String()) m, err := queryUpstream(msg, up) if err == nil { + for _, a := range m.Answer { + log.Debugln("result", a.String()) + } log.Debugln("got reply", m.String()) conn.WriteMsg(m) reply = true diff --git a/server_udp.go b/server_udp.go index 8baa6ec..5c7f909 100644 --- a/server_udp.go +++ b/server_udp.go @@ -14,8 +14,13 @@ func (srv *server) handleUDP(buf []byte, addr net.Addr, conn *net.UDPConn) { return } for _, up := range srv.upstreams { + log.Debugf("from %s query upstream %s", addr, up.String()) + log.Debugln("query", msg.Question[0].String()) m, err := queryUpstream(msg, up) if err == nil { + for _, a := range m.Answer { + log.Debugln("result", a.String()) + } d, _ := m.Pack() conn.WriteTo(d, addr) break diff --git a/upstream.go b/upstream.go index d085402..47b717b 100644 --- a/upstream.go +++ b/upstream.go @@ -35,7 +35,6 @@ func queryUpstream(msg *dns.Msg, upstream *url.URL) (*dns.Msg, error) { } func queryUpstreamUDP(msg *dns.Msg, upstream *url.URL) (*dns.Msg, error) { - log.Debugln("query upstream", upstream.String()) m, _, err := dnsClientUDP.Exchange(msg, upstream.Host) if err != nil { log.Debugf("query udp error %s", err) @@ -44,7 +43,6 @@ func queryUpstreamUDP(msg *dns.Msg, upstream *url.URL) (*dns.Msg, error) { } func queryUpstreamTCP(msg *dns.Msg, upstream *url.URL) (*dns.Msg, error) { - log.Debugln("query upstream", upstream.String()) m, _, err := dnsClientTCP.Exchange(msg, upstream.Host) if err != nil { log.Debugf("query tcp error %s", err) @@ -53,7 +51,6 @@ func queryUpstreamTCP(msg *dns.Msg, upstream *url.URL) (*dns.Msg, error) { } func queryUpstreamTLS(msg *dns.Msg, upstream *url.URL) (*dns.Msg, error) { - log.Debugln("query upstream", upstream.String()) m, _, err := dnsClientTLS.Exchange(msg, upstream.Host) if err != nil { log.Debugf("query tls error %s", err) @@ -62,7 +59,6 @@ func queryUpstreamTLS(msg *dns.Msg, upstream *url.URL) (*dns.Msg, error) { } func queryUpstreamHTTPS(msg *dns.Msg, upstream *url.URL) (*dns.Msg, error) { - log.Debugln("query upstream", upstream.String()) m, _, err := dnsClientHTTPS.Exchange(msg, upstream.String()) if err != nil { log.Debugf("query https error %s", err)