implement subnet detection when connecting to swap repos
One key security protection for the swap process is that it can only happen over the local network. It only works on direct, unrouted connections on the same subnet. The current enforcement is based on checking whether the swap repo is on an Private IPv4 Address. This leaves out IPv6 entirely, as well as local networks that use regular IP addresses. This is more common with IPv6.
This check should move to checking whether the device's WiFi IP address is on the same subnet as the IP address in the swap repo URL. The swap process already gets the device's IP address so it can generate the swap repo URL. I think this just means switching the Mirror.isLocal()
check to use a subnet calculation that works with both IPv4 and IPv6.
Apache Commons Net is already included and should cover this. Otherwise, maybe something like https://seancfoley.github.io/IPAddress/. It think this only needs to support the JVM, for now at least, since swap is unlikely to be implemented in JavaScript/etc or iOS.
@grote feedback about how best to integrate this into the Kotlin Native code would be greatly appreciated. I couldn't find any KTor or Kotlin Native code or libs that does what Apache Commons Net does.