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.
This commit is contained in:
Star Brilliant
2018-04-26 10:17:14 +08:00
parent 1b90731f20
commit c4b2236cf9
4 changed files with 11 additions and 9 deletions

View File

@@ -47,7 +47,7 @@ bootstrap = [
]
# Timeout for upstream request
timeout = 10
timeout = 30
# Disable HTTP Cookies
#

View File

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

View File

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

View File

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