mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-10-24 14:08:27 +02:00
After a wake or a network change, a query to an encrypted upstream can ride a connection opened before the sleep or on the previous network. It times out there, and the query falls back to the OS resolver, which sends it in plaintext on port 53, although a new connection would be answered at once. Every query now checks whether the host slept since the previous one, and if so renews the upstream connections before it is sent. A sleep shows as the wall clock moving ahead of a clock that stops while the host sleeps: Go's monotonic clock on Linux and macOS, and the unbiased interrupt time on Windows, where Go's monotonic clock keeps running. This does not wait for netmon or a wake detector. A wake now also re-bootstraps the upstreams. Before the fallback, a query whose upstreams all failed is retried once on fresh connections when the network epoch moved while it ran: a network change or a wake was handled, or a sleep was found then.