mirror of
https://github.com/zaphar/durnitisp.git
synced 2025-07-22 18:19:48 -04:00
Flag organization and cleanup
This commit is contained in:
parent
368ae10e0f
commit
5a47c31152
@ -19,22 +19,22 @@ use std::sync::{Arc, RwLock};
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
gflags::define! {
|
gflags::define! {
|
||||||
// The size in bytes of the ping requests.
|
/// The size in bytes of the ping requests.
|
||||||
--pingPayload = "durnitisp"
|
--pingPayload = "durnitisp"
|
||||||
}
|
}
|
||||||
|
|
||||||
gflags::define! {
|
gflags::define! {
|
||||||
// The size in bytes of the ping requests.
|
/// The size in bytes of the ping requests.
|
||||||
--pingTTL: u32 = 113
|
--pingTTL: u32 = 113
|
||||||
}
|
}
|
||||||
|
|
||||||
gflags::define! {
|
gflags::define! {
|
||||||
// The size in bytes of the ping requests.
|
/// The size in bytes of the ping requests.
|
||||||
--pingTimeout: u64 = 2048
|
--pingTimeout: u64 = 2048
|
||||||
}
|
}
|
||||||
|
|
||||||
gflags::define! {
|
gflags::define! {
|
||||||
// The size in bytes of the ping requests.
|
/// The size in bytes of the ping requests.
|
||||||
--maxHops: u8 = 50
|
--maxHops: u8 = 50
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
src/main.rs
13
src/main.rs
@ -29,12 +29,12 @@ mod stun;
|
|||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
gflags::define! {
|
gflags::define! {
|
||||||
/// Print this help text.
|
/// Print this help text
|
||||||
-h, --help = false
|
-h, --help = false
|
||||||
}
|
}
|
||||||
|
|
||||||
gflags::define! {
|
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"
|
--listenHost = "0.0.0.0:8080"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +43,11 @@ gflags::define! {
|
|||||||
--debug = false
|
--debug = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gflags::define! {
|
||||||
|
/// Comma separated list of hosts to ping
|
||||||
|
--pingHosts = "google.com"
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
let default_stun_servers: Vec<&'static str> = vec![
|
let default_stun_servers: Vec<&'static str> = vec![
|
||||||
"stun.l.google.com:19302",
|
"stun.l.google.com:19302",
|
||||||
@ -60,8 +65,6 @@ fn main() -> anyhow::Result<()> {
|
|||||||
];
|
];
|
||||||
let mut stun_servers = gflags::parse();
|
let mut stun_servers = gflags::parse();
|
||||||
|
|
||||||
let default_ping_hosts: Vec<&'static str> = vec!["google.com"];
|
|
||||||
|
|
||||||
if HELP.flag {
|
if HELP.flag {
|
||||||
println!("durnitisp <options> <list of hostname:port>");
|
println!("durnitisp <options> <list of hostname:port>");
|
||||||
println!("");
|
println!("");
|
||||||
@ -87,7 +90,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
stun_servers = default_stun_servers;
|
stun_servers = default_stun_servers;
|
||||||
}
|
}
|
||||||
// FIXME(jwall): allow them to override ping hosts
|
// 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));
|
let stop_signal = Arc::new(RwLock::new(false));
|
||||||
|
|
||||||
// Create a Registry and register metrics.
|
// Create a Registry and register metrics.
|
||||||
|
@ -28,7 +28,7 @@ gflags::define! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gflags::define! {
|
gflags::define! {
|
||||||
/// Delay between lookup attempts in seconds.
|
/// Delay between lookup attempts in seconds
|
||||||
--delaySecs: u64 = 60
|
--delaySecs: u64 = 60
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user