Skip to content

Commit 81c8ff7

Browse files
authored
fix(iroh-net): Do not return a port for reqwest DNS resolver (#2906)
## Description A non-zero port is interpreted as overriding the port specified or implied by the URL. Despite the docs not telling you this. That's not really what we want here. ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> ## Notes & open questions seanmonstar/reqwest#2413 (comment) ## 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] Tests if relevant. - [x] All breaking changes documented.
1 parent 91d44dc commit 81c8ff7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

iroh-net/src/netcheck/reportgen.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -891,15 +891,14 @@ async fn check_captive_portal(
891891
if let Some(Host::Domain(domain)) = url.host() {
892892
// Use our own resolver rather than getaddrinfo
893893
//
894-
// For some reason reqwest wants SocketAddr rather than IpAddr but then proceeds to
895-
// ignore the port, extracting it from the URL instead. We supply a dummy port.
894+
// Be careful, a non-zero port will override the port in the URI.
896895
//
897896
// Ideally we would try to resolve **both** IPv4 and IPv6 rather than purely race
898897
// them. But our resolver doesn't support that yet.
899898
let addrs: Vec<_> = dns_resolver
900899
.lookup_ipv4_ipv6_staggered(domain, DNS_TIMEOUT, DNS_STAGGERING_MS)
901900
.await?
902-
.map(|ipaddr| SocketAddr::new(ipaddr, 80))
901+
.map(|ipaddr| SocketAddr::new(ipaddr, 0))
903902
.collect();
904903
builder = builder.resolve_to_addrs(domain, &addrs);
905904
}
@@ -1062,16 +1061,15 @@ async fn measure_https_latency(
10621061
if let Some(Host::Domain(domain)) = url.host() {
10631062
// Use our own resolver rather than getaddrinfo
10641063
//
1065-
// For some reason reqwest wants SocketAddr rather than IpAddr but then proceeds to
1066-
// ignore the port, extracting it from the URL instead. We supply a dummy port.
1064+
// Be careful, a non-zero port will override the port in the URI.
10671065
//
10681066
// The relay Client uses `.lookup_ipv4_ipv6` to connect, so use the same function
10691067
// but staggered for reliability. Ideally this tries to resolve **both** IPv4 and
10701068
// IPv6 though. But our resolver does not have a function for that yet.
10711069
let addrs: Vec<_> = dns_resolver
10721070
.lookup_ipv4_ipv6_staggered(domain, DNS_TIMEOUT, DNS_STAGGERING_MS)
10731071
.await?
1074-
.map(|ipaddr| SocketAddr::new(ipaddr, 80))
1072+
.map(|ipaddr| SocketAddr::new(ipaddr, 0))
10751073
.collect();
10761074
builder = builder.resolve_to_addrs(domain, &addrs);
10771075
}

0 commit comments

Comments
 (0)