diff --git a/src/icmp.rs b/src/icmp.rs index be58f03..5e81008 100644 --- a/src/icmp.rs +++ b/src/icmp.rs @@ -19,22 +19,22 @@ use std::sync::{Arc, RwLock}; use std::time::Duration; gflags::define! { - // The size in bytes of the ping requests. + /// The size in bytes of the ping requests. --pingPayload = "durnitisp" } gflags::define! { - // The size in bytes of the ping requests. + /// The size in bytes of the ping requests. --pingTTL: u32 = 113 } gflags::define! { - // The size in bytes of the ping requests. + /// The size in bytes of the ping requests. --pingTimeout: u64 = 2048 } gflags::define! { - // The size in bytes of the ping requests. + /// The size in bytes of the ping requests. --maxHops: u8 = 50 } diff --git a/src/main.rs b/src/main.rs index f595ecc..89e86a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,12 +29,12 @@ mod stun; mod util; gflags::define! { - /// Print this help text. + /// Print this help text -h, --help = false } gflags::define! { - /// Port to listen on for exporting variables prometheus style. + /// Port to listen on for exporting variables prometheus style --listenHost = "0.0.0.0:8080" } @@ -43,6 +43,11 @@ gflags::define! { --debug = false } +gflags::define! { + /// Comma separated list of hosts to ping + --pingHosts = "google.com" +} + fn main() -> anyhow::Result<()> { let default_stun_servers: Vec<&'static str> = vec![ "stun.l.google.com:19302", @@ -60,8 +65,6 @@ fn main() -> anyhow::Result<()> { ]; let mut stun_servers = gflags::parse(); - let default_ping_hosts: Vec<&'static str> = vec!["google.com"]; - if HELP.flag { println!("durnitisp "); println!(""); @@ -87,7 +90,7 @@ fn main() -> anyhow::Result<()> { stun_servers = default_stun_servers; } // FIXME(jwall): allow them to override ping hosts - let ping_hosts = default_ping_hosts; + let ping_hosts: Vec<&str> = PINGHOSTS.flag.split(",").collect(); let stop_signal = Arc::new(RwLock::new(false)); // Create a Registry and register metrics. diff --git a/src/stun.rs b/src/stun.rs index 343aa78..5ab9ffb 100644 --- a/src/stun.rs +++ b/src/stun.rs @@ -28,7 +28,7 @@ gflags::define! { } gflags::define! { - /// Delay between lookup attempts in seconds. + /// Delay between lookup attempts in seconds --delaySecs: u64 = 60 }