mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-30 14:15:40 +00:00
Add a timeout configuration for server
This commit is contained in:
@@ -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 != "") {
|
||||
|
||||
@@ -17,6 +17,9 @@ upstream = [
|
||||
"8.8.4.4:53",
|
||||
]
|
||||
|
||||
# Upstream timeout
|
||||
timeout = 10
|
||||
|
||||
# Number of tries if upstream DNS fails
|
||||
tries = 3
|
||||
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user