Open amydevs opened 1 year ago
How does one detect changes to the network? Would it just be a matter of polling the os.networkInterfaces()
?
Actually a trick question, because we had worked on this problem a long time ago in Matrix OS. The most efficient way is to make use of netlink sockets to subscribe to OS network changes. However that's not portable and is specific to Linux ecosystem.
We had worked on a netlink interface in Haskell before but didn't get very far... I can see that there's https://github.com/mildsunrise/node_netlink which seems maintained, but it would have to be an entirely different library if we were to wrap it ourselves.
Again such a thing would be platform-specific again. So that would have to be relegated to a later date. The easiest solution for now is just to poll os.networkInterfaces()
every second.
Specification
We should react to the adding or removing network interfaces. This will mean we need to close and open sockets and manage our resource record cache accordingly
Additional context
The RFC provides guidelines on what to do for topology changes https://datatracker.ietf.org/doc/html/rfc6762#section-10.3
Tasks