remove log

dns
Dingjun 8 years ago
parent 1f88a61e05
commit 0eceb283e8

@ -32,7 +32,7 @@ func (h *HTTPDns) getMyIP() string {
} }
type ipAPI struct { type ipAPI struct {
Ip string `json:"origin"` IP string `json:"origin"`
} }
func (h *HTTPDns) queryMyIP() { func (h *HTTPDns) queryMyIP() {
@ -62,7 +62,7 @@ func (h *HTTPDns) queryMyIP() {
return return
} }
//fmt.Printf("got: %s\n", ip.Ip) //fmt.Printf("got: %s\n", ip.Ip)
h.myip = ip.Ip h.myip = ip.IP
} }
func (h *HTTPDns) getMyNet() string { func (h *HTTPDns) getMyNet() string {
@ -130,7 +130,7 @@ type RR struct {
} }
var httpclient = &http.Client{ var httpclient = &http.Client{
Timeout: 3 * time.Second, Timeout: 5 * time.Second,
Transport: &http.Transport{ Transport: &http.Transport{
TLSClientConfig: &tls.Config{ServerName: "dns.google.com"}, TLSClientConfig: &tls.Config{ServerName: "dns.google.com"},
TLSHandshakeTimeout: 3 * time.Second, TLSHandshakeTimeout: 3 * time.Second,

@ -3,7 +3,7 @@ package main
import ( import (
"errors" "errors"
"github.com/miekg/dns" "github.com/miekg/dns"
"log" //"log"
"strings" "strings"
"time" "time"
) )
@ -30,7 +30,7 @@ func (r *routers) checkBlacklist(m *dns.Msg) bool {
} }
if ip != "" && r.c.blacklistIps.has(ip) { 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 return true
} }
@ -49,7 +49,7 @@ func (r *routers) query(m *dns.Msg, servers []addr) (*dns.Msg, error) {
// query cache // query cache
m2 := r.cache.get(m) m2 := r.cache.get(m)
if m2 != nil { 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 m2.Id = m.Id
return m2, nil return m2, nil
} }
@ -66,7 +66,7 @@ func (r *routers) query(m *dns.Msg, servers []addr) (*dns.Msg, error) {
up = r.udp 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) m1, _, err := up.Exchange(m, srv.addr)
if err == nil && !r.checkBlacklist(m) { 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 return m1, err
} }
log.Println(err) //log.Println(err)
lastErr = err lastErr = err
} }
@ -102,7 +102,7 @@ func (r *routers) ServeDNS(w dns.ResponseWriter, m *dns.Msg) {
return 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 // no match or failed, fallback to default
m1, err := r.query(m, r.c.servers) m1, err := r.query(m, r.c.servers)
if err != nil { if err != nil {
log.Println(err) //log.Println(err)
dns.HandleFailed(w, m) dns.HandleFailed(w, m)
} else { } else {
w.WriteMsg(m1) w.WriteMsg(m1)

Loading…
Cancel
Save