From a060407db1b89060567c8e7974db9552700d9701 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 4 Jun 2019 01:37:59 +0200 Subject: [PATCH] Use a different address than 255.255.255.0 for netprobes Windows doesn't seem to like this address. Also default to the fallback resolver IP if there is one and no netprobe_address option in the configuration file. Fix netprobe_timeout = -1 by the way --- dnscrypt-proxy/config.go | 12 +++++++++--- dnscrypt-proxy/example-dnscrypt-proxy.toml | 2 +- dnscrypt-proxy/netprobe_windows.go | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dnscrypt-proxy/config.go b/dnscrypt-proxy/config.go index 7872f206..0ec4192b 100644 --- a/dnscrypt-proxy/config.go +++ b/dnscrypt-proxy/config.go @@ -21,7 +21,8 @@ import ( ) const ( - MaxTimeout = 3600 + MaxTimeout = 3600 + DefaultNetprobeAddress = "9.9.9.9:53" ) type Config struct { @@ -112,7 +113,6 @@ func newConfig() Config { LogMaxBackups: 1, TLSDisableSessionTickets: false, TLSCipherSuite: nil, - NetprobeAddress: "255.255.255.0:53", NetprobeTimeout: 60, OfflineMode: false, RefusedCodeInResponses: false, @@ -425,7 +425,13 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error { netprobeTimeout = *netprobeTimeoutOverride } }) - NetProbe(config.NetprobeAddress, netprobeTimeout) + netprobeAddress := DefaultNetprobeAddress + if len(config.NetprobeAddress) > 0 { + netprobeAddress = config.NetprobeAddress + } else if len(config.FallbackResolver) > 0 { + netprobeAddress = config.FallbackResolver + } + NetProbe(netprobeAddress, netprobeTimeout) if !config.OfflineMode { if err := config.loadSources(proxy); err != nil { return err diff --git a/dnscrypt-proxy/example-dnscrypt-proxy.toml b/dnscrypt-proxy/example-dnscrypt-proxy.toml index b67940af..6fdfe350 100644 --- a/dnscrypt-proxy/example-dnscrypt-proxy.toml +++ b/dnscrypt-proxy/example-dnscrypt-proxy.toml @@ -217,7 +217,7 @@ netprobe_timeout = 60 ## On other operating systems, the connection will be initialized ## but nothing will be sent at all. -netprobe_address = "255.255.255.0:53" +netprobe_address = "9.9.9.9:53" ## Offline mode - Do not use any remote encrypted servers. diff --git a/dnscrypt-proxy/netprobe_windows.go b/dnscrypt-proxy/netprobe_windows.go index 7f767ad9..ae22d944 100644 --- a/dnscrypt-proxy/netprobe_windows.go +++ b/dnscrypt-proxy/netprobe_windows.go @@ -9,7 +9,7 @@ import ( ) func NetProbe(address string, timeout int) error { - if len(address) <= 0 || timeout <= 0 { + if len(address) <= 0 || timeout == 0 { return nil } remoteUDPAddr, err := net.ResolveUDPAddr("udp", address)