Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/core/api/status/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 15 additions & 9 deletions packages/core/api/status/src/route/actor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::HashMap,
net::{IpAddr, SocketAddr},
net::{IpAddr, SocketAddr, ToSocketAddrs},
time::Duration,
};

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<Vec<IpAddr>> {
let resolver = hickory_resolver::Resolver::builder_tokio()?.build();
let addrs = resolver
.lookup_ip(hostname)
.await?
.into_iter()
.collect::<Vec<IpAddr>>();
async fn lookup_dns(hostname: &str, port: u16) -> GlobalResult<Vec<IpAddr>> {
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::<Vec<_>>(),
)
})
.await??;
Comment on lines +321 to +330
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Double unwrap (??) of Result types could mask underlying errors. Consider handling each error case separately for better error reporting.


Ok(addrs)
}
Expand Down
26 changes: 16 additions & 10 deletions packages/core/api/status/src/route/matchmaker.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
net::{IpAddr, SocketAddr},
net::{IpAddr, SocketAddr, ToSocketAddrs},
time::Duration,
};

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -245,17 +245,23 @@ async fn test_lobby_connection(
}

/// Returns the IP addresses for a given hostname.
async fn lookup_dns(hostname: &str) -> GlobalResult<Vec<IpAddr>> {
let resolver = hickory_resolver::Resolver::builder_tokio()?.build();
let addrs = resolver
.lookup_ip(hostname)
.await?
.into_iter()
.collect::<Vec<IpAddr>>();
#[tracing::instrument]
async fn lookup_dns(hostname: &str, port: u16) -> GlobalResult<Vec<IpAddr>> {
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::<Vec<_>>(),
)
})
.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.
Expand Down
Loading