marirs / ifcfg-rs Goto Github PK
View Code? Open in Web Editor NEWGet details of network interfaces
License: MIT License
Get details of network interfaces
License: MIT License
IPv6 link-local addresses are not necessarily globally unique. To use them, you need to also add a "scope ID" when addressing them.
I saw that ifcfg returns SocketAddr
s, which contain a scope_id
for the V6
variant, but it looks like they're not being populated:
fn main() -> Result<(), Box<dyn Error>> {
let interfaces = ifcfg::IfCfg::get().expect("ifcfg");
// for interface in &interfaces {
// println!("{:#?}", interface);
// }
for interface in &interfaces {
for address in &interface.addresses {
if let Some(ref sock_addr) = address.address {
if let SocketAddr::V6(v6_sock_addr) = sock_addr {
println!("scope_id: {} for {}", v6_sock_addr.scope_id(), v6_sock_addr)
}
}
}
}
Ok(())
}
Results: All of theIPv6 addresses across multiple interfaces have scope_id 0
.
I'm just trying to write my first IPv6 networking code, so I don't know how to actually get the scope ID. (Though I was playing around with Deno's new Deno.networkInterfaces()
API yesterday and noticed that the do provide that. Maybe there's an example to follow somewhere in their code?)
also: Thanks for writing this library! ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.