Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for an interface api: "has_link()", code is ready and tested below: #677

omarabdul-hadi started this conversation in Ideas
Discussion options

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?

You must be logged in to vote

Replies: 1 comment

Comment options

Just realized that the windows cmd above takes really long, ~0.6 seconds on my setup at least.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /