messense / if-addrs

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

Create an API for responding to changes in network interfaces #35

Closed mon closed 2 months ago

mon commented 3 months ago

I just noticed this TODO item in the README.

I have code for both Linux (using an AF_NETLINK socket) and Windows (using NotifyAddrChange) to do this, and I'd love to merge it in, but the external API is an open question.

My current use-case needs to receive change events, but also cancel these events on program exit. To do this, my notifiers spawn threads, send change messages via a crossbeam channel, and have custom Drop impls that wake up a side-channel to cancel the thread.

Async could work here, but async rust scares me a little 😅. Do you have any preferences on what the API should look like?

messense commented 3 months ago

IMO blocking API is a good starting point.