diff --git a/README.MD b/README.MD index 72de9a6..5a856e3 100644 --- a/README.MD +++ b/README.MD @@ -17,10 +17,20 @@ Similar as [dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html) ,but support ### Configuration -All the configuration on godns.conf a TOML formating config file. +All the configuration on `godns.conf` a TOML formating config file. More about Toml :[https://github.com/mojombo/toml](https://github.com/mojombo/toml) +#### resolv.conf + +Upstream server can be configuration by change file from somewhere other that "/etc/resolv.conf" + +``` +[resolv] +resolv-file = "/etc/resolv.conf" +``` +If multi `namerserver` set at resolv.conf, the upsteam server will try in order of up to botton + diff --git a/godns.conf b/godns.conf index b09cb1c..85285e0 100644 --- a/godns.conf +++ b/godns.conf @@ -13,7 +13,7 @@ port = 53 [resolv] resolv-file = "/etc/resolv.conf" -timeout = 30 # 30 seconds +timeout = 5 # 5 seconds [redis] host = "kenshinx.me" diff --git a/handler.go b/handler.go index ca132c4..b20e036 100644 --- a/handler.go +++ b/handler.go @@ -43,6 +43,14 @@ func (h *GODNSHandler) do(net string, w dns.ResponseWriter, req *dns.Msg) { mesg, err := h.resolver.Lookup(net, req) + if err != nil { + Debug("%s", err) + dns.HandleFailed(w, req) + return + } + + w.WriteMsg(mesg) + } func (h *GODNSHandler) DoTCP(w dns.ResponseWriter, req *dns.Msg) { diff --git a/resolver.go b/resolver.go index 26a24f5..97274de 100644 --- a/resolver.go +++ b/resolver.go @@ -44,7 +44,6 @@ func (r *Resolver) Lookup(net string, req *dns.Msg) (message *dns.Msg, err error Debug("%s resolv on %s ttl: %d", qname, nameserver, rtt) return r, nil } - Debug("%s dns query failed", qname) return nil, ResolvError{qname, r.Nameservers()} }