feat!: Add a Resolver
trait to abstract over DNS resolvers
#3326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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