Giter VIP home page Giter VIP logo

Comments (12)

QuantumEntangledAndy avatar QuantumEntangledAndy commented on June 11, 2024 1
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.

EstebanBorai avatar EstebanBorai commented on June 11, 2024 1

@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.

EstebanBorai avatar EstebanBorai commented on June 11, 2024

Hi @QuantumEntangledAndy!

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.

QuantumEntangledAndy avatar QuantumEntangledAndy commented on June 11, 2024

Perhaps follow the scheme in this crate

So netmask is an ipv4/6 and broadcast is an Option<ipv4/6>

from local-ip-address.

QuantumEntangledAndy avatar QuantumEntangledAndy commented on June 11, 2024

Also how would your crate handle multiple ip addresses per interface?

from local-ip-address.

QuantumEntangledAndy avatar QuantumEntangledAndy commented on June 11, 2024

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.

EstebanBorai avatar EstebanBorai commented on June 11, 2024

@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.

QuantumEntangledAndy avatar QuantumEntangledAndy commented on June 11, 2024

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.

EstebanBorai avatar EstebanBorai commented on June 11, 2024

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.

QuantumEntangledAndy avatar QuantumEntangledAndy commented on June 11, 2024

I see I'll look out for it then thanks for the heads up.

from local-ip-address.

EstebanBorai avatar EstebanBorai commented on June 11, 2024

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.

EstebanBorai avatar EstebanBorai commented on June 11, 2024

Will close this but feel free to open the issue in the new repo and reference this!

from local-ip-address.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.