[PR #3449] [MERGED] resolver: add Ipv6AndIpv4 strategy #3851

Closed
opened 2026-03-16 12:06:12 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/3449
Author: @Jeidnx
Created: 1/30/2026
Status: Merged
Merged: 2/16/2026
Merged by: @djc

Base: mainHead: ipv6_first_lookup


📝 Commits (4)

  • 80496ac resolver: factor out parallel lookup logic
  • 15342fd resolver: add Ipv6AndIpv4 lookup strategy
  • 1a59f44 resolver: simplify rt_then_swap
  • 33432a6 resolver: make Ipv6AndIpv4 the default lookup strategy

📊 Changes

3 files changed (+125 additions, -46 deletions)

View changed files

📝 crates/resolver/src/config.rs (+4 -2)
📝 crates/resolver/src/lookup_ip.rs (+107 -39)
📝 tests/integration-tests/tests/integration/lookup_tests.rs (+14 -5)

📄 Description

This strategy also tries to query A and AAAA, but crucially orders the result to prefer AAAA records.

Since we can't really have a happy eyeballs implementation without a mechanism to stream dns responses, the next best thing is to give clients both AAAA and A. This allows them to implement "happy eyeballs -like", by resolving and connecting to both v6 and v4 simultaneously, and preferring the v6 connection.

edit: after sleeping over this, the above doesn't make a ton of sense. If a client wanted to implement "happy eyeballs -like", the ordering of the records wouldn't really matter i suppose.
What this does accomplishes is to make sure clients have the option to always prefer ipv6 addresses, when they try connections in the order of the lookup response.

See also this issue in reqwest and this comment by seanmonstar

On the implementation: I just copied the TODO comments, but unsure if they still really apply here. If there would exist a streaming interface, it wouldn't make sense to order the responses. Instead i imagine there would be one option to just stream the responses as soon as they come in, and one option which implements happy eyeballs.

Also maybe consider making this Ipv6AndIpv4 Strategy the default?

And i didn't add any test, since i couldn't find any tests for any of the strategies. If wanted, i could try to add some integration tests for the strategies.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/3449 **Author:** [@Jeidnx](https://github.com/Jeidnx) **Created:** 1/30/2026 **Status:** ✅ Merged **Merged:** 2/16/2026 **Merged by:** [@djc](https://github.com/djc) **Base:** `main` ← **Head:** `ipv6_first_lookup` --- ### 📝 Commits (4) - [`80496ac`](https://github.com/hickory-dns/hickory-dns/commit/80496acf34d1bb88ec8d61412d2a595402bed915) resolver: factor out parallel lookup logic - [`15342fd`](https://github.com/hickory-dns/hickory-dns/commit/15342fd7f11ae2deeac9add3902dd63635a7d889) resolver: add Ipv6AndIpv4 lookup strategy - [`1a59f44`](https://github.com/hickory-dns/hickory-dns/commit/1a59f44653f9b1af574dae834f73c97331874557) resolver: simplify rt_then_swap - [`33432a6`](https://github.com/hickory-dns/hickory-dns/commit/33432a63352a701720d8246ce421be9047e952ea) resolver: make Ipv6AndIpv4 the default lookup strategy ### 📊 Changes **3 files changed** (+125 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `crates/resolver/src/config.rs` (+4 -2) 📝 `crates/resolver/src/lookup_ip.rs` (+107 -39) 📝 `tests/integration-tests/tests/integration/lookup_tests.rs` (+14 -5) </details> ### 📄 Description This strategy also tries to query A and AAAA, but crucially orders the result to prefer AAAA records. Since we can't really have a happy eyeballs implementation without a mechanism to stream dns responses, the next best thing is to give clients both AAAA and A. ~~This allows them to implement "happy eyeballs -like", by resolving and connecting to both v6 and v4 simultaneously, and preferring the v6 connection.~~ edit: after sleeping over this, the above doesn't make a ton of sense. If a client wanted to implement "happy eyeballs -like", the ordering of the records wouldn't really matter i suppose. What this does accomplishes is to make sure clients have the option to always prefer ipv6 addresses, when they try connections in the order of the lookup response. See also [this issue in reqwest](https://github.com/seanmonstar/reqwest/issues/2679) and [this comment by seanmonstar](https://github.com/hickory-dns/hickory-dns/pull/3247#issuecomment-3245738444) On the implementation: I just copied the TODO comments, but unsure if they still really apply here. If there would exist a streaming interface, it wouldn't make sense to order the responses. Instead i imagine there would be one option to just stream the responses as soon as they come in, and one option which implements happy eyeballs. Also maybe consider making this Ipv6AndIpv4 Strategy the default? And i didn't add any test, since i couldn't find any tests for any of the strategies. If wanted, i could try to add some integration tests for the strategies. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 12:06:12 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#3851
No description provided.