feature request: check/monitor local IP addresses
Submitted by Simon McVittie
Link to original bug (#707456)
Description
Some Telepathy- and Farstream-related code wants to enumerate local IP addresses, which is annoyingly non-portable (WSAIoctl() with SIO_GET_INTERFACE_LIST on Windows, getifaddrs() or ioctl() with SIOCGIFCONF on Unix). It would be nice if a GIO extension point - either GNetworkMonitor or a new interface - could wrap this for us.
On Linux, the set of local IP addresses can also be monitored over time with rtnetlink(7), although that's non-portable. Non-Linux platforms would probably need a flag to say "sorry, no change notification" instead.
For https://bugs.freedesktop.org/show_bug.cgi?id=41148 we would also like Telepathy connection managers to be able to detect this situation:
- connected to a wired network with local IP address 192.168.0.42
- also connected to a wireless network with local IP address 10.1.1.42
- TCP connection to a server, bound to local IP address 192.168.0.42
- unplug from wired
- the TCP connection remains up, but is useless unless/until we plug the cable back in
and respond by either disconnecting immediately, disconnecting after a grace period, or probing connectivity (i.e. pinging the server and checking for a reply within a reasonable time). This could either work by having the application ask the GSocket[Connection] for its local IP address and then use the GNetworkMonitor or whatever, or by having the GSocket[Connection] emit a signal when it detects that its local IP address is no longer bound to any interface.
telepathy-gabble has LGPL IP address enumeration code in src/bytestream-socks5.c if it would be helpful.