diff --git a/dnscrypt-proxy/config.go b/dnscrypt-proxy/config.go index 5aaf77c5d4..65f13c81c0 100644 --- a/dnscrypt-proxy/config.go +++ b/dnscrypt-proxy/config.go @@ -447,7 +447,8 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error { } proxy.certRefreshConcurrency = Max(1, config.CertRefreshConcurrency) proxy.certRefreshDelay = time.Duration(Max(60, config.CertRefreshDelay)) * time.Minute - proxy.certRefreshDelayAfterFailure = time.Duration(10 * time.Second) + proxy.certRefreshDelayStartFailure = time.Duration(10 * time.Second) + proxy.certRefreshDelayAfterFailure = time.Duration(30 * time.Minute) proxy.certIgnoreTimestamp = config.CertIgnoreTimestamp proxy.ephemeralKeys = config.EphemeralKeys if len(config.ListenAddresses) == 0 && len(config.LocalDoH.ListenAddresses) == 0 { diff --git a/dnscrypt-proxy/proxy.go b/dnscrypt-proxy/proxy.go index cb9442a76b..10ee8ac372 100644 --- a/dnscrypt-proxy/proxy.go +++ b/dnscrypt-proxy/proxy.go @@ -71,6 +71,7 @@ type Proxy struct { ServerNames []string DisabledServerNames []string requiredProps stamps.ServerInformalProperties + certRefreshDelayStartFailure time.Duration certRefreshDelayAfterFailure time.Duration timeout time.Duration certRefreshDelay time.Duration @@ -252,9 +253,12 @@ func (proxy *Proxy) StartProxy() { if proxy.showCerts { os.Exit(0) } + startSuccesfull := false if liveServers > 0 { + startSuccesfull = true dlog.Noticef("dnscrypt-proxy is ready - live servers: %d", liveServers) } else if err != nil { + startSuccesfull = false dlog.Error(err) dlog.Notice("dnscrypt-proxy is waiting for at least one server to be reachable") } @@ -269,12 +273,15 @@ func (proxy *Proxy) StartProxy() { go func() { for { delay := proxy.certRefreshDelay - if liveServers == 0 { + if liveServers == 0 && startSuccesfull { delay = proxy.certRefreshDelayAfterFailure + } else if liveServers == 0 { + delay = proxy.certRefreshDelayStartFailure } clocksmith.Sleep(delay) liveServers, _ = proxy.serversInfo.refresh(proxy) if liveServers > 0 { + startSuccesfull = true proxy.certIgnoreTimestamp = false } runtime.GC()