From 0eceb283e894b0859b8844a9669d52cac9c28a8c Mon Sep 17 00:00:00 2001 From: Dingjun Date: Thu, 20 Oct 2016 15:12:08 +0800 Subject: [PATCH] remove log --- httpdns.go | 6 +++--- routers.go | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/httpdns.go b/httpdns.go index c399c19..b6f569f 100644 --- a/httpdns.go +++ b/httpdns.go @@ -32,7 +32,7 @@ func (h *HTTPDns) getMyIP() string { } type ipAPI struct { - Ip string `json:"origin"` + IP string `json:"origin"` } func (h *HTTPDns) queryMyIP() { @@ -62,7 +62,7 @@ func (h *HTTPDns) queryMyIP() { return } //fmt.Printf("got: %s\n", ip.Ip) - h.myip = ip.Ip + h.myip = ip.IP } func (h *HTTPDns) getMyNet() string { @@ -130,7 +130,7 @@ type RR struct { } var httpclient = &http.Client{ - Timeout: 3 * time.Second, + Timeout: 5 * time.Second, Transport: &http.Transport{ TLSClientConfig: &tls.Config{ServerName: "dns.google.com"}, TLSHandshakeTimeout: 3 * time.Second, diff --git a/routers.go b/routers.go index aec0495..3039c6e 100644 --- a/routers.go +++ b/routers.go @@ -3,7 +3,7 @@ package main import ( "errors" "github.com/miekg/dns" - "log" + //"log" "strings" "time" ) @@ -30,7 +30,7 @@ func (r *routers) checkBlacklist(m *dns.Msg) bool { } if ip != "" && r.c.blacklistIps.has(ip) { - log.Printf("%s is in blacklist.\n", ip) + //log.Printf("%s is in blacklist.\n", ip) return true } @@ -49,7 +49,7 @@ func (r *routers) query(m *dns.Msg, servers []addr) (*dns.Msg, error) { // query cache m2 := r.cache.get(m) if m2 != nil { - log.Printf("query %s, reply from cache\n", m.Question[0].Name) + //log.Printf("query %s, reply from cache\n", m.Question[0].Name) m2.Id = m.Id return m2, nil } @@ -66,7 +66,7 @@ func (r *routers) query(m *dns.Msg, servers []addr) (*dns.Msg, error) { up = r.udp } - log.Printf("query %s use %s:%s\n", m.Question[0].Name, srv.network, srv.addr) + //log.Printf("query %s use %s:%s\n", m.Question[0].Name, srv.network, srv.addr) m1, _, err := up.Exchange(m, srv.addr) if err == nil && !r.checkBlacklist(m) { @@ -77,7 +77,7 @@ func (r *routers) query(m *dns.Msg, servers []addr) (*dns.Msg, error) { return m1, err } - log.Println(err) + //log.Println(err) lastErr = err } @@ -102,7 +102,7 @@ func (r *routers) ServeDNS(w dns.ResponseWriter, m *dns.Msg) { return } - log.Println(err) + //log.Println(err) } } @@ -110,7 +110,7 @@ func (r *routers) ServeDNS(w dns.ResponseWriter, m *dns.Msg) { // no match or failed, fallback to default m1, err := r.query(m, r.c.servers) if err != nil { - log.Println(err) + //log.Println(err) dns.HandleFailed(w, m) } else { w.WriteMsg(m1)