Posts

Post not yet marked as solved
2 Replies
1.9k Views
I`m trying to make my own OpenVPN client using NetworkExtension. I'm following these instructions:https://github.com/ss-abramchuk/OpenVPNAdapterBut I cant get it to work. I create my manager succesfully, without any errors. But then when I call startTunnel() nothing happens. No error (I have my try/catch in place) and nothing in the log. I have the NetworkExtension entitlements in both my targets. This is the code in question:NETunnelProviderManager.loadAllFromPreferences { (managers, error) in guard error == nil else { NSLog("Unexpected error: \(error)."); return } / if (managers?.count != 0) { do { NSLog("Found VPN with target \(managers?[0].localizedDescription)") managers?[0].isEnabled = true; try managers?[0].connection.startVPNTunnel(); } catch { NSLog("Unexpected error: \(error)."); } } / else { NSLog("Not found, creating new"); let manager = NETunnelProviderManager(); / guard let configurationFileURL = Bundle.main.url(forResource: "config", withExtension: "ovpn"), let configurationFileContent = try? Data(contentsOf: configurationFileURL) else { fatalError() } let tunnelProtocol = NETunnelProviderProtocol() tunnelProtocol.serverAddress = "" tunnelProtocol.providerBundleIdentifier = "com.vpn.***.TunnelManager"; tunnelProtocol.providerConfiguration = ["ovpn": configurationFileContent] manager.protocolConfiguration = tunnelProtocol manager.localizedDescription = "My VPN" manager.isEnabled = true / manager.saveToPreferences(completionHandler: { (error) in if let error = error { print(error); } manager.loadFromPreferences(completionHandler: {(error) in do { try manager.connection.startVPNTunnel(); } catch { NSLog("Unexpected error: \(error)."); } }) }); }I changed the blunde identifier for privacy reasons.I hope somebody can help me with my problem, if you need the contents of another file, or any other information, please ask.Thanks in advance.
Posted
by asirtec.
Last updated
.
Post not yet marked as solved
3 Replies
950 Views
Greetings,We have been strugling for some days implementing our VPN protocol over NEPacketTunnelProvider. It works as a split tunnel, that redirects some connections over it (it doesn't add the default route in the included routes list) but every DNS query must be redirected throught the tunnel.The way we implement this is with 'matchDomains = [""]', and it should redirect every DNS query through the tunnel, making it the default.But sometimes, after a reconnection, when the DNS server doesn't answer in time during normal use (internet browsing, chat, social media, etc...) iOS falls back to another DNS and doesn't use ours until the VPN is reconnected.We would like to know how to avoid this behavior, and force the connection to go only over our servers, even if they never answer.Thanks in advance.
Posted
by asirtec.
Last updated
.