VPNTunnelProviderManager

After running the code the status showing invalid and VPN Disconnected automatically. What is the serveraddress should I use? Here is my VPNConfiguration code.

private func initVPNTunnelProviderManager() {

NETunnelProviderManager.loadAllFromPreferences { (savedManagers: [NETunnelProviderManager]?, error: Error?) in

if let error = error {

print(error)

}

if let savedManagers = savedManagers {

if savedManagers.count > 0 {

self.vpnManager = savedManagers[0]

}

}

self.vpnManager.loadFromPreferences(completionHandler: { (error:Error?) in

if let error = error {

print(error)

}

let providerProtocol = NETunnelProviderProtocol()

providerProtocol.providerBundleIdentifier = self.tunnelBundleId

providerProtocol.providerConfiguration = ["port": self.serverPort,

"server": self.serverAddress,

"ip": self.ip,

"subnet": self.subnet,

"mtu": self.mtu,

"dns": self.dns

]

providerProtocol.serverAddress = self.serverAddress

self.vpnManager.protocolConfiguration = providerProtocol

self.vpnManager.localizedDescription = "VPN Returns"

self.vpnManager.isEnabled = true

self.vpnManager.saveToPreferences(completionHandler: { (error:Error?) in

if let error = error {

print(error)

} else {

print("Save successfully")

}

})

self.VPNStatusDidChange(nil)

})

}

}

Then i wrote the VPN status on the button action. NEVPNStatusInvalid = 0 NEVPNStatusDisconnected = 1 NEVPNStatusConnecting = 2 NEVPNStatusConnected = 3 NEVPNStatusReasserting = 4 NEVPNStatusDisconnecting = 5 Now the status is 0 and 5

Replies

What server address are you using presently ?


Note: you should better move this thread to Networking part of the forum.

Claude31 wrote:

you should better move this thread to Networking part of the forum.

Good advice. I moved it over (-:

manu19906 wrote:

What is the serveraddress should I use?

I recently addressed (hey hey) this question right here on DevForums; see this post for details.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"