From a315e2b3e49c357b7a4f43c86add2d1d56b24838 Mon Sep 17 00:00:00 2001 From: Diva M Date: Mon, 20 May 2024 00:34:50 -0500 Subject: [PATCH] use staggered options and turn on tests --- iroh-net/src/discovery/dns.rs | 5 ++++- iroh-net/src/netcheck/reportgen.rs | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/iroh-net/src/discovery/dns.rs b/iroh-net/src/discovery/dns.rs index 8c8428474a..d850daf579 100644 --- a/iroh-net/src/discovery/dns.rs +++ b/iroh-net/src/discovery/dns.rs @@ -11,6 +11,7 @@ use crate::{ /// The n0 testing DNS node origin pub const N0_DNS_NODE_ORIGIN: &str = "dns.iroh.link"; +const DNS_STAGGERING_MS: &[u64] = &[200, 300]; /// DNS node discovery /// @@ -54,7 +55,9 @@ impl Discovery for DnsDiscovery { let resolver = ep.dns_resolver().clone(); let origin_domain = self.origin_domain.clone(); let fut = async move { - let node_addr = resolver.lookup_by_id(&node_id, &origin_domain).await?; + let node_addr = resolver + .staggered_lookup_by_id(&node_id, &origin_domain, DNS_STAGGERING_MS) + .await?; Ok(DiscoveryItem { provenance: "dns", last_updated: None, diff --git a/iroh-net/src/netcheck/reportgen.rs b/iroh-net/src/netcheck/reportgen.rs index 2085610bde..227440aaf6 100644 --- a/iroh-net/src/netcheck/reportgen.rs +++ b/iroh-net/src/netcheck/reportgen.rs @@ -73,6 +73,9 @@ const ENOUGH_NODES: usize = 3; const DNS_TIMEOUT: Duration = Duration::from_secs(3); +/// Delay used to perform staggered dns queries. +const DNS_STAGGERING_MS: &[u64] = &[200, 300]; + /// Holds the state for a single invocation of [`netcheck::Client::get_report`]. /// /// Dropping this will cancel the actor and stop the report generation. @@ -192,7 +195,7 @@ struct Actor { /// /// This is essentially the summary of all the work the [`Actor`] is doing. outstanding_tasks: OutstandingTasks, - /// The DNS resolver to use for probes that need to resolve DNS records + /// The DNS resolver to use for probes that need to resolve DNS records. dns_resolver: DnsResolver, } @@ -945,7 +948,10 @@ async fn get_relay_addr( ProbeProto::StunIpv4 | ProbeProto::IcmpV4 => match relay_node.url.host() { Some(url::Host::Domain(hostname)) => { debug!(?proto, %hostname, "Performing DNS A lookup for relay addr"); - match dns_resolver.lookup_ipv4(hostname, DNS_TIMEOUT).await { + match dns_resolver + .staggered_lookup_ipv4(hostname, DNS_TIMEOUT, DNS_STAGGERING_MS) + .await + { Ok(mut addrs) => addrs .next() .map(ip::to_canonical) @@ -962,7 +968,10 @@ async fn get_relay_addr( ProbeProto::StunIpv6 | ProbeProto::IcmpV6 => match relay_node.url.host() { Some(url::Host::Domain(hostname)) => { debug!(?proto, %hostname, "Performing DNS AAAA lookup for relay addr"); - match dns_resolver.lookup_ipv6(hostname, DNS_TIMEOUT).await { + match dns_resolver + .staggered_lookup_ipv6(hostname, DNS_TIMEOUT, DNS_STAGGERING_MS) + .await + { Ok(mut addrs) => addrs .next() .map(ip::to_canonical) @@ -1316,7 +1325,6 @@ mod tests { // // TODO: Not sure what about IPv6 pings using sysctl. #[tokio::test] - #[cfg_attr(target_os = "windows", ignore = "flaky")] async fn test_icmpk_probe_eu_relayer() { let _logging_guard = iroh_test::logging::setup(); let pinger = Pinger::new();