diff --git a/packages/core/api/status/Cargo.toml b/packages/core/api/status/Cargo.toml index 8733f1ef5e..97d317d9e5 100644 --- a/packages/core/api/status/Cargo.toml +++ b/packages/core/api/status/Cargo.toml @@ -41,7 +41,6 @@ game-resolve-name-id.workspace = true game-namespace-resolve-name-id.workspace = true token-create.workspace = true -hickory-resolver = "0.25.1" rivet-config.workspace = true rivet-env.workspace = true diff --git a/packages/core/api/status/src/route/actor.rs b/packages/core/api/status/src/route/actor.rs index 21696723c9..2fec99c2d4 100644 --- a/packages/core/api/status/src/route/actor.rs +++ b/packages/core/api/status/src/route/actor.rs @@ -1,6 +1,6 @@ use std::{ collections::HashMap, - net::{IpAddr, SocketAddr}, + net::{IpAddr, SocketAddr, ToSocketAddrs}, time::Duration, }; @@ -263,7 +263,7 @@ pub async fn status( #[tracing::instrument] async fn test_actor_connection(hostname: &str, port: u16, actor_origin: &str) -> GlobalResult<()> { // Look up IP for the actor's host - let gg_ips = lookup_dns(hostname).await?; + let gg_ips = lookup_dns(hostname, port).await?; ensure_with!( !gg_ips.is_empty(), INTERNAL_STATUS_CHECK_FAILED, @@ -315,13 +315,19 @@ async fn test_actor_connection(hostname: &str, port: u16, actor_origin: &str) -> /// Returns the IP addresses for a given hostname. #[tracing::instrument] -async fn lookup_dns(hostname: &str) -> GlobalResult> { - let resolver = hickory_resolver::Resolver::builder_tokio()?.build(); - let addrs = resolver - .lookup_ip(hostname) - .await? - .into_iter() - .collect::>(); +async fn lookup_dns(hostname: &str, port: u16) -> GlobalResult> { + let addr = format!("{hostname}:{port}"); + + // Use native resolver in a blocking task + let addrs = tokio::task::spawn_blocking(move || { + GlobalResult::Ok( + addr.to_socket_addrs()? + .into_iter() + .map(|x| x.ip()) + .collect::>(), + ) + }) + .await??; Ok(addrs) } diff --git a/packages/core/api/status/src/route/matchmaker.rs b/packages/core/api/status/src/route/matchmaker.rs index b15ca88a87..73f3b3cd79 100644 --- a/packages/core/api/status/src/route/matchmaker.rs +++ b/packages/core/api/status/src/route/matchmaker.rs @@ -1,5 +1,5 @@ use std::{ - net::{IpAddr, SocketAddr}, + net::{IpAddr, SocketAddr, ToSocketAddrs}, time::Duration, }; @@ -194,7 +194,7 @@ async fn test_lobby_connection( let token = &player.token; // Look up IP for GG nodes - let gg_ips = lookup_dns(hostname).await?; + let gg_ips = lookup_dns(hostname, 443).await?; ensure_with!( !gg_ips.is_empty(), INTERNAL_STATUS_CHECK_FAILED, @@ -245,17 +245,23 @@ async fn test_lobby_connection( } /// Returns the IP addresses for a given hostname. -async fn lookup_dns(hostname: &str) -> GlobalResult> { - let resolver = hickory_resolver::Resolver::builder_tokio()?.build(); - let addrs = resolver - .lookup_ip(hostname) - .await? - .into_iter() - .collect::>(); +#[tracing::instrument] +async fn lookup_dns(hostname: &str, port: u16) -> GlobalResult> { + let addr = format!("{hostname}:{port}"); + + // Use native resolver in a blocking task + let addrs = tokio::task::spawn_blocking(move || { + GlobalResult::Ok( + addr.to_socket_addrs()? + .into_iter() + .map(|x| x.ip()) + .collect::>(), + ) + }) + .await??; Ok(addrs) } - /// Tests HTTP connectivity to a hostname for a given address. /// /// This lets us isolate of a specific GG IP address is not behaving correctly.