From c4b2236cf9ac6cdf9e8e08991efc407b225a77b3 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Thu, 26 Apr 2018 10:17:14 +0800 Subject: [PATCH] Do not respond to network error, silently fail to prevent caching of SERVFAIL Hopefully we can improve the availability of DoH under unstable network environments. --- doh-client/doh-client.conf | 2 +- doh-client/ietf.go | 6 ++---- doh-client/version.go | 6 ++++-- doh-server/version.go | 6 ++++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doh-client/doh-client.conf b/doh-client/doh-client.conf index 413b490..7d67ca7 100644 --- a/doh-client/doh-client.conf +++ b/doh-client/doh-client.conf @@ -47,7 +47,7 @@ bootstrap = [ ] # Timeout for upstream request -timeout = 10 +timeout = 30 # Disable HTTP Cookies # diff --git a/doh-client/ietf.go b/doh-client/ietf.go index bc4e625..5615737 100644 --- a/doh-client/ietf.go +++ b/doh-client/ietf.go @@ -134,9 +134,8 @@ func (c *Client) generateRequestIETF(w dns.ResponseWriter, r *dns.Msg, isTCP boo if len(requestURL) < 2048 { req, err = http.NewRequest("GET", requestURL, nil) if err != nil { + // Do not respond, silently fail to prevent caching of SERVFAIL log.Println(err) - reply.Rcode = dns.RcodeServerFailure - w.WriteMsg(reply) return &DNSRequest{ err: err, } @@ -144,9 +143,8 @@ func (c *Client) generateRequestIETF(w dns.ResponseWriter, r *dns.Msg, isTCP boo } else { req, err = http.NewRequest("POST", upstream, bytes.NewReader(requestBinary)) if err != nil { + // Do not respond, silently fail to prevent caching of SERVFAIL log.Println(err) - reply.Rcode = dns.RcodeServerFailure - w.WriteMsg(reply) return &DNSRequest{ err: err, } diff --git a/doh-client/version.go b/doh-client/version.go index 1a90665..9edb98b 100644 --- a/doh-client/version.go +++ b/doh-client/version.go @@ -23,5 +23,7 @@ package main -const VERSION = "1.3.3" -const USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)" +const ( + VERSION = "1.3.3" + USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)" +) diff --git a/doh-server/version.go b/doh-server/version.go index 1a90665..9edb98b 100644 --- a/doh-server/version.go +++ b/doh-server/version.go @@ -23,5 +23,7 @@ package main -const VERSION = "1.3.3" -const USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)" +const ( + VERSION = "1.3.3" + USER_AGENT = "DNS-over-HTTPS/" + VERSION + " (+https://github.com/m13253/dns-over-https)" +)