AdguardTeam / dnsproxy

Simple DNS proxy with DoH, DoT, DoQ and DNSCrypt support
Apache License 2.0
2.44k stars 247 forks source link

Hardcoded upstream timeout #333

Closed D13410N3 closed 1 year ago

D13410N3 commented 1 year ago

Config example:

listen-addrs:
  - 127.0.0.1

listen-ports:
  - 5300

verbose: true

upstream:
  - '2.3.4.5:53'

fallback:
  - '8.8.8.8:53'

2.3.4.5:53 - example of incorrect resolver

Fallback is used only after 20 seconds timeout:

2023/06/06 14:32:27 27924#7 [debug] 2.3.4.5:53: response: exchanging with 2.3.4.5:53 over udp: read udp 10.42.0.121:50883->2.3.4.5:53: i/o timeout
2023/06/06 14:32:27 27924#7 [debug] github.com/AdguardTeam/dnsproxy/proxy.exchangeWithUpstream(): upstream 2.3.4.5:53 failed to exchange ;yandex.ru.    IN   A in 20.001921875s. Cause: exchanging with 2.3.4.5:53 over udp: read udp 10.42.0.121:50883->2.3.4.5:53: i/o timeout
2023/06/06 14:32:27 27924#7 [debug] github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).replyFromUpstream(): RTT: 20.0020085s
2023/06/06 14:32:27 27924#7 [debug] github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).replyFromUpstream(): using the fallback upstream due to exchanging with 2.3.4.5:53 over udp: read udp 10.42.0.121:50883->2.3.4.5:53: i/o timeout
2023/06/06 14:32:27 27924#7 [debug] 8.8.8.8:53: sending request A yandex.ru.
2023/06/06 14:32:27 27924#7 [debug] bootstrap: dialing 8.8.8.8:53 (1/1)
2023/06/06 14:32:27 27924#7 [debug] bootstrap: connection to 8.8.8.8:53 succeeded in 256.5µs
2023/06/06 14:32:27 27924#7 [debug] 8.8.8.8:53: response: ok
2023/06/06 14:32:27 27924#7 [debug] 8.8.8.8:53: sending request A yandex.ru.
2023/06/06 14:32:27 27924#7 [debug] bootstrap: dialing 8.8.8.8:53 (1/1)
2023/06/06 14:32:27 27924#7 [debug] bootstrap: connection to 8.8.8.8:53 succeeded in 5.163541ms
2023/06/06 14:32:27 27924#7 [debug] 8.8.8.8:53: response: ok
2023/06/06 14:32:27 27924#7 [debug] upstream 8.8.8.8:53 exchanged ;yandex.ru.   IN   A successfully in 42.495083ms

It'd be nice if we can set timeout value as flag / config field, instead of hardcoded

iJorgen commented 1 year ago

Should these still be hardcoded or also use the new config-setting?!

https://github.com/AdguardTeam/dnsproxy/blob/c70af9f4173e733b06b31d887634c61813fadd25/proxy/proxy.go#L30 https://github.com/AdguardTeam/dnsproxy/blob/c70af9f4173e733b06b31d887634c61813fadd25/upstream/upstream_dot.go#L23