Fixed getting IP address from CLI

This commit is contained in:
Luke Else 2023-02-11 21:22:24 +00:00
parent f2ad0de89b
commit 4f8412f3d0

View File

@ -9,15 +9,15 @@ fn main() {
loop {
let mut ip = String::new();
io::stdin().read_line(&mut ip).unwrap();
let ip_address = match IpAddr::from_str(x) {
let ip_address = match IpAddr::from_str(&ip.trim()) {
Err(_) => {
println!("fucked it");
IpAddr::V4(0, 0, 0, 0)
println!("{} is an invalid IP Address... Please try again", ip);
continue;
},
Ok(ip) => ip,
};
println!("you entered, {:?}", ip_address);
}
}