diff --git a/doh-server/config.go b/doh-server/config.go index 6be4747..1f5ccf5 100644 --- a/doh-server/config.go +++ b/doh-server/config.go @@ -34,6 +34,7 @@ type config struct { Key string `toml:"key"` Path string `toml:"path"` Upstream []string `toml:"upstream"` + Timeout uint `toml:"timeout"` Tries uint `toml:"tries"` TCPOnly bool `toml:"tcp_only"` Verbose bool `toml:"verbose"` @@ -58,8 +59,11 @@ func loadConfig(path string) (*config, error) { if len(conf.Upstream) == 0 { conf.Upstream = []string { "8.8.8.8:53", "8.8.4.4:53" } } + if conf.Timeout == 0 { + conf.Timeout = 10 + } if conf.Tries == 0 { - conf.Tries = 3 + conf.Tries = 1 } if (conf.Cert != "") != (conf.Key != "") { diff --git a/doh-server/doh-server.conf b/doh-server/doh-server.conf index f1bec3f..768eaea 100644 --- a/doh-server/doh-server.conf +++ b/doh-server/doh-server.conf @@ -17,6 +17,9 @@ upstream = [ "8.8.4.4:53", ] +# Upstream timeout +timeout = 10 + # Number of tries if upstream DNS fails tries = 3 diff --git a/doh-server/server.go b/doh-server/server.go index d409445..b986bbd 100644 --- a/doh-server/server.go +++ b/doh-server/server.go @@ -52,9 +52,11 @@ func NewServer(conf *config) (s *Server) { conf: conf, udpClient: &dns.Client { Net: "udp", + Timeout: time.Duration(conf.Timeout) * time.Second, }, tcpClient: &dns.Client { Net: "tcp", + Timeout: time.Duration(conf.Timeout) * time.Second, }, servemux: http.NewServeMux(), }