works at console for linux

This commit is contained in:
Trevor Merritt 2025-04-14 09:37:28 -04:00
parent c50857f210
commit ef1d3dde9c
3 changed files with 36 additions and 36 deletions

View File

@ -1,6 +1,6 @@
10.3.100.1
10.13.31.1
10.13.32.1
10.11.31.3
10.12.32.1
10.11.21.1
10.12.22.1
8.8.8.8

View File

@ -1,7 +1,7 @@
10.2.100.1
10.11.21.1
10.12.22.1
10.13.31.1
10.13.32.1
10.11.31.3
10.12.32.1
8.8.8.8
1.1.1.1

View File

@ -12,17 +12,19 @@ use std::time::{Duration, SystemTime};
use ansi_term::Colour::{Green, Red};
use clap::Parser;
use log::{debug, error, log_enabled, info, Level};
#[derive(Clone)]
struct HistoricHost {
pub name: String,
pub address: Ipv4Addr,
pub history: Vec<u128>,
pub alive: bool
pub alive: bool,
}
#[derive(Clone, Debug)]
struct PingResult {
pub address: Ipv4Addr,
pub rtt: u128
pub rtt: u128,
}
impl HistoricHost {
@ -65,10 +67,10 @@ impl HistoricHost {
match result {
0 => {
self.history.push(ping_duration.as_millis())
},
}
1 => {
println!("Error ping to {}", self.name);
},
}
_ => {
println!("General Ping Error.");
}
@ -79,7 +81,7 @@ impl HistoricHost {
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct PPArgs {
pub targets: Option<PathBuf>
pub targets: Option<PathBuf>,
}
@ -92,7 +94,6 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
}
fn main() {
env_logger::init();
let args = PPArgs::parse();
@ -128,9 +129,9 @@ fn main() {
hosts.push(
HistoricHost {
name: target.to_string(),
address: Ipv4Addr::from_str(&target).unwrap_or(Ipv4Addr::new(127,0,0,1)),
address: Ipv4Addr::from_str(&target).unwrap_or(Ipv4Addr::new(127, 0, 0, 1)),
history: vec![],
alive: false
alive: false,
}
)
}
@ -178,7 +179,6 @@ fn main() {
if rtt == u128::MAX {
// error!("[DT] No reply from {}", addr);
println!("{} not responding", Red.paint(addr.to_string()));
} else {
// debug!("[DT] Recieved a ping result from {} with time of {}", addr, rtt);
println!("{} responding.", Green.paint(addr.to_string()));
@ -190,7 +190,7 @@ fn main() {
info!("Keep Alive Thread Starting.");
let _ = thread::spawn(move || {
let mut counter = 0 ;
let mut counter = 0;
loop {
thread::sleep(Duration::from_millis(1000));
counter += 1;