-
Notifications
You must be signed in to change notification settings - Fork 302
Commit 7bd657e
authored
feat: add a DNS resolver trait (#3473)
## Description
Replaces #2116
Fixes #3468
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.
To not pay the cost of boxing when using the default hickory-based
resolver, the iroh `DnsResolver` internally contains an enum which is
either the default resolver or the boxed custom resolver.
Users can implement the `Resolver` trait on whatever struct to use a
completely custom DNS resolver.
## Breaking Changes
Changes in `iroh_relay::dns` (reexported from `iroh::dns`):
* `DnsResolver::lookup_txt` now returns `impl Iterator<Item =
TxtRecord>`
* `TxtLookup` and `TXT` are removed.
Changes in `iroh_relay::node_info` (reexported from `iroh::discovery`):
* `NodeInfo::from_txt_lookup` now takes `domain_name: String, lookup:
impl Iterator<Item = crate::dns::TxtRecordData>`
Moved items:
* `iroh_relay::node_info::LookupError` was moved to
`iroh_relay::dns::LookupError`
## Notes & open questions
We likely want to still add a builder for our DnsResolver to allow
setting a few more of the common options on the hickory resolver. But
with this, people that want to use some completely custom way of
resolving DNS records can do so.
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
## Change checklist
<!-- Remove any that are not relevant. -->
- [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.
- [ ] Tests if relevant.
- [x] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
- [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
- [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
- [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
- [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
- [ ] [`sendme`](https://github.com/n0-computer/sendme)1 parent 2b36b77 commit 7bd657eCopy full SHA for 7bd657e
File tree
Expand file treeCollapse file tree
2 files changed
+388
-252
lines changedFilter options
- iroh-relay/src
Expand file treeCollapse file tree
2 files changed
+388
-252
lines changed
0 commit comments