First of all, thank you, your code is super helpful.
I need to change the
tunSettings.dnsSettings = NEDNSSettings(servers: [])
based on the user current IP address (wifi or cellular ) -- I'm listen to network events with Reachability library and together with on-demand rules I thought I can simply do
Hi!
First of all, thank you, your code is super helpful.
I need to change the
tunSettings.dnsSettings = NEDNSSettings(servers: [])
based on the user current IP address (wifi or cellular ) -- I'm listen to network events with Reachability library and together with on-demand rules I thought I can simply doreachability.whenReachable = { reachability in if reachability.connection == .wifi { self.stopTunnel(with: .none, completionHandler: {print("asdasd")}) } else { self.stopTunnel(with: .none, completionHandler: {print("asdasd")}) } }
but it doesn't stop the tunnel, when I debug it, I can see that it's been called , but the tunnel stays connected..
when I manually turn the connection off, the on-demand rules kick off and my startTunnel function called.
To summarize, I want to be able to reconfigure NEPacketTunnelNetworkSettings object every time the user changes his public ip.
Thank you very much!