Fix command line parsing
Former-commit-id: b36693f619525c3c6196bcefbb77d566f7618364 [formerly 10726be9d050b3891b797ecebba9dcc8a45dfb7e] [formerly b8295a04bd8f5d591c677e1bded1e4a5bb1e5af6 [formerly 28d443681b6d9b94a719203e746f9a3d542fac46]] Former-commit-id: 8f77fc39adff92421852e6ed5e296e46e446f605 [formerly 9a8ef64aa90ff4880d4a90c9bfd57509ee705e6c] Former-commit-id: 743d161581e3752f138426cd854b2dcfde055dfe Former-commit-id: b8d50c1746aa5295980a02fb5b1be0a55d682cbc Former-commit-id: 981c8d7404e0bbf3b2884c4c72df27c0a49b4df1 Former-commit-id: ae68f651b57fcad5316c9d38f76a1a911bf2797e [formerly 1d4b878c54c39c4baece82f3811c6cdb8f2022ce] Former-commit-id: 2859f6d56f92d30a8becdb052ef72399a8824c54
This commit is contained in:
parent
016cfe91ef
commit
f3fd006978
1 changed files with 2 additions and 7 deletions
|
@ -203,16 +203,11 @@ fn parse_local_bind(arg: &str) -> Result<(SocketAddr, &str), io::Error> {
|
|||
(IpAddr::V6(ipv6_addr), remaining)
|
||||
} else {
|
||||
// Maybe ipv4 addr
|
||||
let Some((ipv4_str, remaining)) = arg.split_once(':') else {
|
||||
return Err(Error::new(
|
||||
ErrorKind::InvalidInput,
|
||||
format!("cannot parse IPv4 bind from {}", arg),
|
||||
));
|
||||
};
|
||||
let (ipv4_str, remaining) = arg.split_once(':').unwrap_or((arg, ""));
|
||||
|
||||
match Ipv4Addr::from_str(ipv4_str) {
|
||||
Ok(ip4_addr) => (IpAddr::V4(ip4_addr), remaining),
|
||||
// Must be the port, so we default to ipv6 bind
|
||||
// Must be the port, so we default to ipv4 bind
|
||||
Err(_) => (IpAddr::V4(Ipv4Addr::from_str("127.0.0.1").unwrap()), arg),
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue