Skip to content

Commit

Permalink
use staggered options and turn on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
divagant-martian committed May 20, 2024
1 parent 173e841 commit a315e2b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion iroh-net/src/discovery/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 12 additions & 4 deletions iroh-net/src/netcheck/reportgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a315e2b

Please sign in to comment.