Files
firezone/rust/connlib
Thomas Eizinger ed6e2a4e7d feat(connlib): introduce DoHUrl abstraction (#10881)
When connlib processes DoH queries, we need to pass the server's URL
around a lot. In order to bootstrap the HTTP client, we need to extract
the host part of this URL and resolve it for IP addresses using the
system resolver. A regular URL doesn't necessarily have a host: It could
be relative. This creates an error path within our code that _should_
never get hit for DoH URLs as those are always absolute.

To avoid this error path, we follow the "parse, don't validate" approach
typical among strongly typed languages. We create our own type that can
only be constructed from absolute URLs. If we receive a URL from the
portal that is not absolute, we already fail at the deserialization
step. Using data privacy of the encapsulated url, we can then guarantee
that the host-part of the URL is always there and can access it in an
infallible way.

Given that we are now already parsing the URL to begin with, I've also
opted to directly implement an optimisation where we create a fast-path
for the 4 known DoH providers that we have which allows us to pass them
around and copy them without incurring extra allocations.

Finally, this custom type also comes with its own Display/Debug
implementation, making the log output a bit easier to read.
2025-11-16 23:38:06 +00:00
..

Connlib

Firezone's connectivity library shared by all clients.

Building Connlib

You shouldn't need to build connlib directly; it's typically built as a dependency of one of the other Firezone components. See READMEs in those directories for relevant instructions.