Comments (12)
enum IfAddr {
V4(IfAddrV4),
V6(IfAddrV6),
}
struct IfAddrV4 {
ip_address: IpAddrV4,
subnet: IpAddrV4,
broadcast: Option<IpAddrV4>
}
struct IfAddrV6 {
ip_address: IpAddrV6,
subnet: IpAddrV6,
broadcast: Option<IpAddrV6>
}
from local-ip-address.
@QuantumEntangledAndy given that we are going further into different getifaddrs implementations for (as of today) 3 target operative systems, I will be moving the logic to handle network interfaces to its own crate and will have this crate for local-ip-address only (as the name suggest), which will consume this other getifaddrs-based crate to gather host's local IP address.
from local-ip-address.
Thanks for the interest in this crate, yes I'am designing an API at the moment, there's very good insights so far including this feature request from you.
As of now I have this structure which I discussed already with @zyddnys here: #24
enum NetworkInterfaceAddress {
AfInet,
AfInet6,
}
struct NetworkInterface {
name: String,
ip_address: Option<IpAddr>,
family: NetworkInterfaceFamily,
}
For this feature request I would have to define these types (subnet mask and broadcast address) to make them compatible with macOS, Linux and Windows (in order to offer the same API).
Any ideas/contributions are welcome!
Do you have an idea of how we could extend the current draft to support these fields you are requesting?
from local-ip-address.
Perhaps follow the scheme in this crate
So netmask is an ipv4/6
and broadcast is an Option<ipv4/6>
from local-ip-address.
Also how would your crate handle multiple ip addresses per interface?
from local-ip-address.
What about something like this?
struct NetworkInterface {
name: String,
ip_addresses: Vec<IfAddr>,
family: NetworkInterfaceFamily,
}
struct IfAddr {
ip_address: IpAddr,
subnet: IpAddr,
broadcast: Option<IpAddr>
}
Also how do you handle interfaces with both v4 and v6 family?
from local-ip-address.
@QuantumEntangledAndy looks good so far.
Also how would your crate handle multiple ip addresses per interface?
We would have to provide a Vec<IpAddr>
then, IpAddr
already covers IpV4
and IpV6
so it's solved unless I'm missing something?
Perhaps follow the scheme in this crate
Will take a look! Thanks for referencing!
from local-ip-address.
Well ipaddr subnet and broadcast will all be ipv4 or ipv6 as a set. So could have IfAddr as an enum of ifaddr4/ifaddr6 at that level rather than at the IP level. Maybe could skip the family that way as it's encoded on the enum.
from local-ip-address.
Hi @QuantumEntangledAndy! I have been working on the support for extra interface info here:
https://github.com/EstebanBorai/local-ip-address/tree/feat/additional-interface-info
Please let me know any suggestions and insights.
I would like to open a discussion for this so we keep all the relevant comments there, what do you think?
from local-ip-address.
I see I'll look out for it then thanks for the heads up.
from local-ip-address.
I see I'll look out for it then thanks for the heads up.
Okey! Here it is: https://github.com/EstebanBorai/network-interface
So this issue basically turned into a crate (?).
I've moved my work on the branch I been working on here wrt additional interface data into that crate so feel free to open issues or we could have a discussion with RFC for version 0.1.0.
I've published a v0.1.0-beta so we can install it and play around easily.
Thanks again @QuantumEntangledAndy! Hope to see you there!
from local-ip-address.
Will close this but feel free to open the issue in the new repo and reference this!
from local-ip-address.
Related Issues (20)
- Cannot compile for Windows MSVC on Linux HOT 5
- Incorrect local IP address got on Windows HOT 4
- Hope to support FreeBSD OS HOT 3
- Use Os Error HOT 5
- Release HOT 6
- Use `std::alloc::alloc` instead of `libc::malloc` HOT 2
- Misleading error message when using non-`en0` interface on macOS HOT 1
- Update `neli` to latest version or change approach
- Determine the primary outbound local IP if multiple present in interfaces HOT 1
- conditional compilation for WebAssembly HOT 1
- MacOS bug on 0.5.0 HOT 6
- Compilation error with version local-ip-address-0.5.2 HOT 7
- error: build failed HOT 1
- Unexpected "\0" in the network interface name HOT 3
- failed to resolve: use of undeclared crate or module `env` HOT 2
- New release for windows-sys 0.48 HOT 3
- [linux] ipv6 address reported on wrong (moving) interface alias
- Feature Request: Determining Netmask HOT 1
- thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: LocalIpAddressNotFound', HOT 7
- Why local_ip() return IpAddr? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from local-ip-address.