mirror of
https://github.com/status-im/nim-chronos.git
synced 2026-08-27 13:01:12 +00:00
Using `tunnel`, a general TCP tunnel can be created for any protocol via a HTTP proxy. This tunnel is typically used for establishing TLS connections via a proxy but any protocol can be used. When a tunnel is established, the connection is removed from the session pool and given to the caller who is now responsible for closing it. Because the tunnel connection itself can be encrypted, we return an `AsyncStream` that the caller must close (rather than a `StreamTransport`). This PR also moves DNS name resolution to the connection provider - this has the effect of delaying DNS lookup until the actual connect attempt is made - earlier, DNS lookups would happen when creating the HTTP address. The move allows the proxy to perform the name resolution when relevant - the move also prepares the API for async name resolution. Callers can still skip name resolution by providing an explicit list of addresses to connect to.