-
Notifications
You must be signed in to change notification settings - Fork 236
feat!: Add a Resolver
trait to abstract over DNS resolvers
#3326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3326/docs/iroh/ Last updated: 2025-05-27T11:31:00Z |
d9d6f7e
to
5168b02
Compare
I am not convinced this amount of boxing is really worth it, I'd rather not have a trait, and simply wrap hickory types for 1.0 stability |
OK, then we'd need to add a builder to allow setting more options, no? Right now we don't allow configuring apart from |
Description
This adds a
Resolver
trait to abstract over DNS resolution. It contains methods to resolve IPv4 or IPv6 addresses, and TXT records. Because the trait needs to be dyn-compatible for our usage (we don't want to have a generic for the DNS resolver on the Endpoint), all methods return boxed futures that contain boxed iterators.The
DnsResolver
struct is changed to contain anArc<dyn Resolver>
instead of being hardcoded tohickory_resolver::TokioResolver
. Iroh ships an implementation ofResolver
forhickory_resolver::TokioResolver
, but does not have any hickory types in the public API anymore.Users can implement the
Resolver
trait on whatever struct to use a completely custom DNS resolver.Breaking Changes
Changes in
iroh_relay::dns
(reexported fromiroh::dns
):DnsResolver::new
now takes animpl Resolver
. To create a default resolver, useDnsResolver::default
or the equivalentDnsResolver::new_with_system_defaults
DnsResolver::lookup_txt
now returnsimpl Iterator<Item = TxtRecord>
TxtLookup
andTXT
are removed.Changes in
iroh_relay::node_info
(reexported fromiroh::discovery
):NodeInfo::from_txt_lookup
now takesname: String, lookup: impl Iterator<Item = crate::dns::TxtRecord>
Notes & open questions
We could now put the implementation of
Resolver
forhickory_resolver::TokioResolver
behind a (default) feature flag to not have to hard-depend on a specific version of hickory_resolver anymore during iroh 1.0 - I think? Or maybe we'd still have to newtype it. Will need to think about this some more.Change checklist
quic-rpc
iroh-gossip
iroh-blobs
dumbpipe
sendme