Skip to content

Commit 13d14bb

Browse files
committed
fix: swap status monitor dns resolver with native resolver
1 parent 97d2838 commit 13d14bb

File tree

1 file changed

+15
-9
lines changed
  • packages/core/api/status/src/route

1 file changed

+15
-9
lines changed

packages/core/api/status/src/route/actor.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{
22
collections::HashMap,
3-
net::{IpAddr, SocketAddr},
3+
net::{IpAddr, SocketAddr, ToSocketAddrs},
44
time::Duration,
55
};
66

@@ -263,7 +263,7 @@ pub async fn status(
263263
#[tracing::instrument]
264264
async fn test_actor_connection(hostname: &str, port: u16, actor_origin: &str) -> GlobalResult<()> {
265265
// Look up IP for the actor's host
266-
let gg_ips = lookup_dns(hostname).await?;
266+
let gg_ips = lookup_dns(hostname, port).await?;
267267
ensure_with!(
268268
!gg_ips.is_empty(),
269269
INTERNAL_STATUS_CHECK_FAILED,
@@ -315,13 +315,19 @@ async fn test_actor_connection(hostname: &str, port: u16, actor_origin: &str) ->
315315

316316
/// Returns the IP addresses for a given hostname.
317317
#[tracing::instrument]
318-
async fn lookup_dns(hostname: &str) -> GlobalResult<Vec<IpAddr>> {
319-
let resolver = hickory_resolver::Resolver::builder_tokio()?.build();
320-
let addrs = resolver
321-
.lookup_ip(hostname)
322-
.await?
323-
.into_iter()
324-
.collect::<Vec<IpAddr>>();
318+
async fn lookup_dns(hostname: &str, port: u16) -> GlobalResult<Vec<IpAddr>> {
319+
let addr = format!("{hostname}:{port}");
320+
321+
// Use native resolver in a blocking task
322+
let addrs = tokio::task::spawn_blocking(move || {
323+
GlobalResult::Ok(
324+
addr.to_socket_addrs()?
325+
.into_iter()
326+
.map(|x| x.ip())
327+
.collect::<Vec<_>>(),
328+
)
329+
})
330+
.await??;
325331

326332
Ok(addrs)
327333
}

0 commit comments

Comments
 (0)