adds ability to read hosts.txt if no file is specified on the command line, using defaults if hosts.txt is missing

This commit is contained in:
Trevor Merritt 2025-04-23 15:03:16 -04:00
parent e1b435bf7b
commit 6d55d96ca7
3 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,4 @@
address,name
10.3.100.1,Belleville Router 10.3.100.1,Belleville Router
10.11.31.3,Belleville VPN 11-31 10.11.31.3,Belleville VPN 11-31
10.12.32.1,Belleville VPN 12-32 10.12.32.1,Belleville VPN 12-32

View File

@ -1,3 +1,4 @@
address,name
10.3.100.1,Belleville Router 10.3.100.1,Belleville Router
10.11.31.3,Belleville VPN 11-31 10.11.31.3,Belleville VPN 11-31
10.12.32.1,Belleville VPN 12-32 10.12.32.1,Belleville VPN 12-32

View File

@ -21,7 +21,6 @@ const SECONDS_IN_MINUTE: u32 = 60;
const SECONDS_IN_HOUR: u32 = SECONDS_IN_MINUTE * 60; const SECONDS_IN_HOUR: u32 = SECONDS_IN_MINUTE * 60;
const SECONDS_IN_DAY: u32 = SECONDS_IN_HOUR * 24; const SECONDS_IN_DAY: u32 = SECONDS_IN_HOUR * 24;
pub fn duration_to_string(to_convert: Duration) -> String { pub fn duration_to_string(to_convert: Duration) -> String {
let mut total_seconds = to_convert.as_secs() as u32; let mut total_seconds = to_convert.as_secs() as u32;
let mut working_string = String::new(); let mut working_string = String::new();
@ -169,7 +168,15 @@ impl PPState {
let settings = AppSettings::parse(); let settings = AppSettings::parse();
print!("Prep to load targets..."); print!("Prep to load targets...");
let mut targets = PPState::build_targets_from_file(settings.ping_host_file); let file_to_check = match settings.ping_host_file {
None => {
PathBuf::from("./hosts.txt")
}
Some(actual) => {
actual
}
};
let mut targets = PPState::build_targets_from_file(Some(file_to_check));
// channel to send requests to ping // channel to send requests to ping
let (ping_response_sender, ping_response_listener) = mpsc::channel::<PingResult>(); let (ping_response_sender, ping_response_listener) = mpsc::channel::<PingResult>();