use IpAddr type for validation and add error messages

From: https://github.com/ekzhang/bore/pull/162#discussion_r2042195219
This commit is contained in:
confor
2025-04-14 16:36:05 -04:00
parent e137357267
commit 53dad89514
3 changed files with 35 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
#![allow(clippy::items_after_test_module)]
use std::net::SocketAddr;
use std::net::IpAddr;
use std::time::Duration;
use anyhow::{anyhow, Result};
@@ -23,8 +24,8 @@ async fn spawn_server(secret: Option<&str>) {
Server::new(
1024..=65535,
secret,
"0.0.0.0".to_string(),
"0.0.0.0".to_string(),
"0.0.0.0".parse::<IpAddr>().unwrap(),
"0.0.0.0".parse::<IpAddr>().unwrap(),
)
.listen(),
);
@@ -136,7 +137,7 @@ fn empty_port_range() {
let _ = Server::new(
min_port..=max_port,
None,
"0.0.0.0".to_string(),
"0.0.0.0".to_string(),
"0.0.0.0".parse::<IpAddr>().unwrap(),
"0.0.0.0".parse::<IpAddr>().unwrap(),
);
}