You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
We used to have more-or-less identical code in various places to set a
static DNS resolver and add a few extension methods on the
`hickory_resolver::TokioResolver`. This PR cleans this up and makes all
of iroh use the same resolver, defined in a single place, as a newtype
struct around the `TokioResolver` from `hickory_resolver`:
* Adds a newtype struct `DnsResolver` around
`hickory_resolver::TokioResolver` in `iroh_relay::dns`. It lives (for
now) in `iroh_relay`, because this is a the bottom of our dependency
chain: both `iroh` and `iroh-net-report` need to use it as well, and
both depend on `iroh_relay`.
* Adds most methods from the previous extension traits to the
`DnsResolver` struct
* Changes all imports to use this `DnsResolver` now instead of the
previous type alias to TokioResolver
* Removes all now-obsolete duplicate extension traits and type aliases
and duplicated tests
* Removes the global `static` DnsResolver that was accessible via
`iroh::dns::default_resolver`. This means that by default multiple
endpoints in the same app would not share the DnsResolver. However, I'd
say a) it is not too common to use multiple endpoints, and b) if you do
and want to share the DnsResolver, you can still do so by creating the
DnsResolver yourself and cloning it into the endpoint builder.
* Cleans up and aligns the various methods on `DnsResolver`, and newtype
the types from hickory so that this public iroh API does not depend on
hickory types (apart from a `From<TokioResolver> for DnsResolver`, which
is deferred to a follow-up to investigate)
The only place outside of tests and examples where a new `DnsResolver`
is constructed is in endpoint builder if no custom DnsResolver is set.
This means: As long as an app has a single endpoint only, there will
only be one DnsResolver.
## Breaking Changes
* `iroh::dns::resolver` and `iroh::dns::default_resolver` are removed.
There is no static, global DNS resolver anymore. If you want to share a
DNS resolver between endpoints, create the resolver yourself with
`iroh::dns::DnsResolver::new` and clone it into the endpoint builders
(in `EndpointBuilder::dns_resolver`). If you want to reuse the DNS
resolver from an endpoint, you can access it with
`Endpoint::dns_resolver` and clone it to wherever you need it.
* `iroh::dns::DnsResolver` used to be a type alias and now is a reexport
of `iroh_relay::dns::DnsResolver` struct
* `iroh::dns::node_info` module is now a reexport of
`iroh_relay::dns::node_info`
* `iroh::dns::node_info::{IrohAttr, TxtAttrs,
node_id_from_hickory_name}` are no longer public. Use
`iroh::dns::DnsResolver::lookup_node_by_id` or
`iroh::dns::DnsResolver::lookup_node_by_domain_name` to lookup node info
from DNS.
* `iroh::dns::node_info::{to_z32, from_z32}`are removed. Use the methods
on `iroh::dns::node_info::NodeIdExt` trait instead.
* `iroh::discovery::dns::{N0_DNS_NODE_ORIGIN_PROD,
N0_DNS_NODE_ORIGIN_STAGING}` are now reexports of
`iroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING}`
* `iroh::dns::ResolverExt` is removed. Use the methods on
`iroh::dns::DnsResolver` instead.
* The methods in `iroh::dns::DnsResolver` now take an `impl ToString`
instead of `impl hickory_proto::rr::domain::IntoName` for their `host`
argument
* `iroh::test_utils::create_dns_resolver` is removed, use
`iroh::dns::DnsResolver::new` instead
## Notes & open questions
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] All breaking changes documented.
0 commit comments