-
Notifications
You must be signed in to change notification settings - Fork 323
Add support for an interface api: "has_link()", code is ready and tested below: #677
omarabdul-hadi
started this conversation in
Ideas
-
On linux interface.is_running(); seems to indicate whether or not a link is present, albeit api name is misleading in that regard, and api is not available on windows
On macos this will tell us whether or not there is link:
let cmd = format!("ifconfig {:}", interface.name);
let output = std::process::Command::new("sh").arg("-c").arg(cmd).output().expect("running process failed");
let rslt = std::str::from_utf8(&(output.stdout)).unwrap();
!rslt.contains("inactive")
On windows, this will tell us whether or not there is link:
let cmd = format!("wmic nic where description='{:}' get NetEnabled", .interface.description);
let output = std::process::Command::new("cmd").arg("/c").arg(&cmd).output().expect("running process failed");
let rslt = std::str::from_utf8(&(output.stdout)).unwrap();
rslt.contains("TRUE")
Can we please add support for this?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Just realized that the windows cmd above takes really long, ~0.6 seconds on my setup at least.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment