From 7937330185bac4bc85a97e417cdf1543bcb3e9e7 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 17 Feb 2024 04:11:56 +0100 Subject: [PATCH] fix: try all addresses, in case resolves ipv6 too --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 32f922f..23c793f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,12 +35,13 @@ async fn ping_server(Query(options): Query) -> Result Err(format!("invalid address: {e}")), - Ok(mut addrs) => match addrs.next() { - None => Err("could not resolve host".to_string()), - Some(addr) => match ping_mumble_server(addr).await { - Err(e) => Err(format!("could not ping server: {e}")), - Ok(info) => Ok(Json(info)), + Ok(addrs) => { + for addr in addrs { + if let Ok(info) = ping_mumble_server(addr).await { + return Ok(Json(info)); + } } + Err("could not resolve host".to_string()) } } }