Created
December 13, 2023 04:54
-
-
Save appare45/be915c9167b3b37b41cc453117fe9854 to your computer and use it in GitHub Desktop.
get list of NIC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nix::ifaddrs; | |
fn main() { | |
println!("Hello, world!"); | |
let addrs = nix::ifaddrs::getifaddrs().unwrap(); | |
for ifaddr in addrs { | |
match ifaddr.address { | |
Some(address) => { | |
println!("interface {} address {}", ifaddr.interface_name, address); | |
} | |
None => { | |
println!( | |
"interface {} with unsupported address family", | |
ifaddr.interface_name | |
); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment