common: resolve ping addresses with async DNS #36
+3
-4
@@ -25,12 +25,11 @@ pub struct ServerStatus {
|
||||
#[cfg(feature = "networking")]
|
||||
pub async fn ping_server(address: &str, port: u16) -> color_eyre::Result<ServerStatus> {
|
||||
use color_eyre::eyre::{bail, eyre};
|
||||
use std::net::ToSocketAddrs;
|
||||
use std::time::Duration;
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::net::{lookup_host, UdpSocket};
|
||||
|
||||
let dest = format!("{}:{}", address, port)
|
||||
.to_socket_addrs()?
|
||||
let dest = lookup_host(format!("{}:{}", address, port))
|
||||
.await?
|
||||
.next()
|
||||
.ok_or_else(|| eyre!("could not resolve address"))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user