32 lines
827 B
Rust
32 lines
827 B
Rust
use std::{io};
|
|
|
|
use crate::networking::Network;
|
|
|
|
|
|
mod networking;
|
|
|
|
#[allow(unused_variables, unused_mut, unused_assignments)]
|
|
fn main() {
|
|
println!("Enter the IP and cidr for your given network");
|
|
|
|
let ip_and_cidr: (networking::ip::IpAddr, u8);
|
|
|
|
loop {
|
|
let mut ip_buf = String::new();
|
|
io::stdin().read_line(&mut ip_buf).unwrap_or_default();
|
|
|
|
ip_and_cidr = match networking::ip_and_cidr_from_string(&ip_buf) {
|
|
Err(_) => {
|
|
println!("{} is an invalid IP Address... Please try again", ip_buf);
|
|
continue;
|
|
},
|
|
Ok(ip_and_cidr) => ip_and_cidr
|
|
};
|
|
|
|
break;
|
|
}
|
|
|
|
let networks = Network::create_subnet(&ip_and_cidr.0, ip_and_cidr.1);
|
|
println!("IP: {}, CIDR: {}", ip_and_cidr.0.to_string(), ip_and_cidr.1);
|
|
}
|