OpenVPNAdapter
OpenVPNAdapter copied to clipboard
VPN Status returning nil
When my app goes to the background and is returning to the foreground, the VPN status returns nil but the VPN icon is still showing on the screen of the device. This is how i query for status self.vpnManager.manager?.connection.status
cc @ss-abramchuk
@djubreel To get connection information, you should call a openVPNAdapter.connectionInformation
.
@ss-abramchuk But this property available only in the App Network Extension. But what if I need to pass this data to the host app? I have no idea how to reach that.
Do you have solutions for that purpose?
Hi @djubreel, have you tried to reload the manager using NETunnelProviderManager.loadAllFromPreferences
?
Hi @AndriiDoroshko, you can use MMWormhole framework or if you don't want one more dependency in your project you can use UserDefaults initialized with custom suite name.
@AndriiDoroshko @ss-abramchuk I noticed that after a long time maybe 10 minutes or the device is locked, when I request for the status, it gives nil but I can still see the VPN logo and the IP is that of the VPN server. Seeming like the app can't communicate with/control the VPN. Any idea what could be the cause? How can I go about fixing it?
@djubreel i don't really realise your problem. But, keep in mind, If you run VPN as App Extension, it's gonna be a separate process. If your phone is locked, iOS may kill your app's process. But App Extension process still alive, that's why you can see VPN logo on the status bar. Currently i'm working on the project with using this library. So i can provide inspiration when i finished.
Thanks @AndriiDoroshko
Hello @AndriiDoroshko @ss-abramchuk. I tried using Wormhole and UserDefaults but couldn't get them to work. What I did was save a value in my app and then added an observer in the start method of the PackettunnelProvider. Any idea why it might not be working?
@djubreel I have 1000 ideas why it doesn't work. First of all, to pass data between processes you have to use UserDefaults(suitName: "YourSuitName"), Your host app and extension app has to be in the same app group https://medium.com/ios-os-x-development/shared-user-defaults-in-ios-3f15cd2c9409. Do you use ReactiveSwift or RXSwift?
Thanks, @AndriiDoroshko, I'm using neither. I'm using KVO instead and I have all that was in the article you shared. I was thinking it might have to do with where I attached the observer which was in the startTunnel method of the packettunnelprovider class.
@ss-abramchuk my app can't seem to communicate with the VPN App extension after about three minutes, any idea what the cause could be? I have tried using wormhole library and user-defaults to no avail