messense / if-addrs

Retrieve IP addresses for all interfaces. POSIX & Windows
BSD 3-Clause "New" or "Revised" License
23 stars 16 forks source link

Add idx field to Interface #24

Closed shinypb closed 1 year ago

shinypb commented 1 year ago

Knowing the interface index (also known as the interface number) is required for setting some socket options, particularly around IPv6 multicasting (e.g. UdpSocket#join_multicast_v6).

This adds an idx field on Interface (an Option<u32>) and populates it on posix systems. Unfortunately, I am not a Windows programmer, so I'm leaving it unimplemented there; I would be delighted to see someone else pick up the torch and get it implemented on Windows as well.

messense commented 1 year ago

Thanks, there are some build/test failures though.

shinypb commented 1 year ago

I see that! Thought cargo test had my back  😅I need to spin up some test VMs; I’ll dig in on Monday 💪.

shinypb commented 1 year ago

Hi @messense! I fixed the build errors and added an additional assertion in the test case; please let me know if there's anything else I can do on this PR. Thanks for your review! :bow:

messense commented 1 year ago

Published in v0.10.0: https://crates.io/crates/if-addrs/0.10.0