Skip to content

Commit

Permalink
Disable interface on Windows. Closes #440
Browse files Browse the repository at this point in the history
  • Loading branch information
orf committed Dec 16, 2024
1 parent 6b54ce4 commit eee18b0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions gping/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct Args {
/// Resolve ping targets to IPv6 address
#[arg(short = '6', conflicts_with = "ipv4")]
ipv6: bool,

#[cfg(not(target_os = "windows"))]
/// Interface to use when pinging.
#[arg(short = 'i', long)]
interface: Option<String>,
Expand Down Expand Up @@ -390,6 +392,11 @@ fn main() -> Result<()> {
));
}

#[cfg(not(target_os = "windows"))]
let interface: Option<String> = args.interface.clone();
#[cfg(target_os = "windows")]
let interface: Option<String> = None;

let (key_tx, rx) = mpsc::channel();

let mut threads = vec![];
Expand All @@ -411,11 +418,11 @@ fn main() -> Result<()> {
Duration::from_millis((args.watch_interval.unwrap_or(0.2) * 1000.0) as u64);

let mut ping_opts = if args.ipv4 {
PingOptions::new_ipv4(host_or_cmd, interval, args.interface.clone())
PingOptions::new_ipv4(host_or_cmd, interval, interface.clone())
} else if args.ipv6 {
PingOptions::new_ipv6(host_or_cmd, interval, args.interface.clone())
PingOptions::new_ipv6(host_or_cmd, interval, interface.clone())
} else {
PingOptions::new(host_or_cmd, interval, args.interface.clone())
PingOptions::new(host_or_cmd, interval, interface.clone())
};
if let Some(ping_args) = &args.ping_args {
ping_opts = ping_opts.with_raw_arguments(ping_args.clone());
Expand Down

0 comments on commit eee18b0

Please sign in to comment.