I am creating an application to connect to a VPN server. I have worked out how to do this, but need to be able to send all traffic over the connection. Is there any code which can do this? So far I have tried:
let manager: NEVPNManager = NEVPNManager.sharedManager()
var p = NEVPNProtocolIPSec()
manager.`protocol` = p
let pw = ""
p.username = ""
p.passwordReference = pw.dataUsingEncoding(NSUTF8StringEncoding)
p.serverAddress = ""
p.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
//p.sharedSecretReference = getPasscodeNSData("vpnSharedSecret")
p.useExtendedAuthentication = true
p.disconnectOnSleep = false
From Apple:
This is the default routing method. The IP routes are specified by the Packet Tunnel Provider extension at the time that the VPN tunnel is fully established. See NETunnelProvider for more details.
This is something the is specified from the Server end typically, l2tp does allow the user to toggle this setting. For that, take a look at routingMethod
part of the NETunnelProvider. Scroll down to the Routing Network Data to the VPN
section for the information you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With