INNER CODE UNIT · Rust
Ok
CluvexStudio/Aether · aether/src/lib.rs:209
if let Ok(peer) = text.parse::<SocketAddr>() {
return Ok(peer);
}
// An address with the port left off is the likely slip, so name what is
// missing rather than calling the whole thing unreadable.
let portless = text.parse::<IpAddr>().ok().or_else(|| {
text.strip_prefix('[')
.and_then(|rest| rest.strip_suffix(']'))
.and_then(|inner| inner.parse::<IpAddr>().ok())
});
if let Some(address) = portless {
return Err(AetherError::Other(format!(
"{text} carries no port, and the port is required; write it out, as in {}",
SocketAddr::new(address, WG_EXAMPLE_PORT)
)));
}