Skip to content

Conversation

Frando
Copy link
Member

@Frando Frando commented Sep 29, 2025

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.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • 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:

@Frando Frando force-pushed the Frando/dns-resolver-trait branch from 68a623a to 0254fd6 Compare September 29, 2025 10:31
Copy link

github-actions bot commented Sep 29, 2025

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3473/docs/iroh/

Last updated: 2025-09-30T07:48:29Z

Copy link

github-actions bot commented Sep 29, 2025

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 3ed393b

@n0bot n0bot bot added this to iroh Sep 29, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Sep 29, 2025
@dignifiedquire dignifiedquire added this to the v0.99.0 milestone Sep 29, 2025
Copy link
Contributor

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@Frando Frando enabled auto-merge September 30, 2025 07:47
@Frando Frando added this pull request to the merge queue Sep 30, 2025
Merged via the queue into main with commit 7bd657e Sep 30, 2025
52 of 55 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Sep 30, 2025
github-merge-queue bot pushed a commit that referenced this pull request Sep 30, 2025
## Description

Based on #3473 

In addition to the trait added in #3473 ,this adds a builder to allow
setting more than one custom nameserver on the default hickory resolver,
and to allow using other protocols than UDP.

The additional protocols are DNS over TCP, TLS, and HTTPS. For the
latter two I enabled the `https` feature of `hickory-resolver` - this
doesn't add any new dependencies, as tokio-rustls and h2 are in the tree
already through reqwest.

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

There's two more protocols [supported by
hickory](https://docs.rs/hickory-proto/latest/hickory_proto/xfer/enum.Protocol.html)
though behind non-default feature flags: Quic and H3. If there's demand,
we could enable those too.

## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] 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.
- [ ] 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Decide about hickory in public API for DnsResolver
2 participants