mirror of
https://git.alemi.dev/mumble-stats-api.git
synced 2024-11-22 16:04:49 +01:00
fix: try all addresses, in case resolves ipv6 too
This commit is contained in:
parent
734de0bde5
commit
7937330185
1 changed files with 6 additions and 5 deletions
11
src/main.rs
11
src/main.rs
|
@ -35,12 +35,13 @@ async fn ping_server(Query(options): Query<PingOptions>) -> Result<Json<ServerIn
|
||||||
let tuple = (options.host, options.port.unwrap_or(64738));
|
let tuple = (options.host, options.port.unwrap_or(64738));
|
||||||
match tuple.to_socket_addrs() {
|
match tuple.to_socket_addrs() {
|
||||||
Err(e) => Err(format!("invalid address: {e}")),
|
Err(e) => Err(format!("invalid address: {e}")),
|
||||||
Ok(mut addrs) => match addrs.next() {
|
Ok(addrs) => {
|
||||||
None => Err("could not resolve host".to_string()),
|
for addr in addrs {
|
||||||
Some(addr) => match ping_mumble_server(addr).await {
|
if let Ok(info) = ping_mumble_server(addr).await {
|
||||||
Err(e) => Err(format!("could not ping server: {e}")),
|
return Ok(Json(info));
|
||||||
Ok(info) => Ok(Json(info)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err("could not resolve host".to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue