I am trying to create a flutter+swift app for iOS which could determine if there is an active VPN connection and which could determine if my app is communicating via VPN.
Currently, I am trying to check in my app, if there is any network interface like these (if there is, that would mean the VPN connection is active):
tap, tun, ppp, ipsec, ipsec0, utun1, utun2, pptp
Unfortunately, this doesn't work well. On some iOS devices, I see that there is an existing "ipsec" interface, but there is actually no VPN connection. And on some other devices, I see it working correctly (mostly iOS14+).
I read about it, and it seems that "ipsec" interface is often used for handling WiFi calls and to communicate between Apple devices. Is this right? Does it mean that it's not determinable if this interface will be set (because it can be controlled by the network provider or by the Apple ecosystem)?
I am also wondering if there is a reliable way to tell if the device has an active VPN connection, or at least tell if the given app is using a per-app VPN at the moment?