iroh/
dns.rs

1//! This module exports a DNS resolver, which is also the default resolver used in the
2//! [`crate::Endpoint`] if no custom resolver is configured.
3//!
4//! The resolver provides methods to resolve domain names to ipv4 and ipv6 addresses,
5//! and to resolve node ids to node addresses.
6//!
7//! See the [`node_info`](crate::node_info) module documentation for details on how
8//! iroh node records are structured.
9
10pub use iroh_relay::dns::{DnsResolver, N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING};
11
12#[cfg(test)]
13pub(crate) mod tests {
14    use std::time::Duration;
15
16    use tracing_test::traced_test;
17
18    use super::DnsResolver;
19    use crate::defaults::staging::NA_RELAY_HOSTNAME;
20
21    const TIMEOUT: Duration = Duration::from_secs(5);
22    const STAGGERING_DELAYS: &[u64] = &[200, 300];
23
24    #[tokio::test]
25    #[traced_test]
26    async fn test_dns_lookup_ipv4_ipv6() {
27        let resolver = DnsResolver::new();
28        let res: Vec<_> = resolver
29            .lookup_ipv4_ipv6_staggered(NA_RELAY_HOSTNAME, TIMEOUT, STAGGERING_DELAYS)
30            .await
31            .unwrap()
32            .collect();
33        assert!(!res.is_empty());
34        dbg!(res);
35    }
36}