Don't wait for the whole server list before accepting connections

Blocking until all servers have been checked is safe, but significantly
increases startup times.

OTOH, we shouldn't accept connections unless we have at least one live
server.

So, a better approach may be to add the ability for `serversInfo.refresh()`
to write to a channel after a live server has been found, and block on
that channel in the main thread before accepting client connections.
This commit is contained in:
Frank Denis 2020-05-31 13:24:35 +02:00
parent 3d5f877058
commit d59d9427b3
1 changed files with 1 additions and 1 deletions

View File

@ -215,6 +215,7 @@ func (proxy *Proxy) StartProxy() {
for _, registeredServer := range proxy.registeredServers {
proxy.serversInfo.registerServer(registeredServer.name, registeredServer.stamp)
}
proxy.startAcceptingClients()
liveServers, err := proxy.serversInfo.refresh(proxy)
if liveServers > 0 {
proxy.certIgnoreTimestamp = false
@ -233,7 +234,6 @@ func (proxy *Proxy) StartProxy() {
dlog.Error(err)
dlog.Notice("dnscrypt-proxy is waiting for at least one server to be reachable")
}
proxy.startAcceptingClients()
go func() {
for {
clocksmith.Sleep(PrefetchSources(proxy.xTransport, proxy.sources))