add debug log

nghttp2
fangdingjun 6 years ago
parent 90d650c118
commit 4aa5ef896e

@ -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()

@ -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

@ -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

@ -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

@ -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)

Loading…
Cancel
Save