I’ve built-in the OpenVPN XOR library for connecting OpenVPN(https://github.com/FuturraGroup/OpenVPNXor)
I can add the configuration file in to gadget and in a position to join the VPN on iPhone
gadget (iOS 16.2 model) however it’s not reflecting any historical past in Open VPN server and after approximate in 1 minute it will get disconnected mechanically.Please refer the screenshot hooked up.
Unusual factor is that it doesn’t mirror on any historical past on Server i.e. no logs historical past for connection or disconnection or consumer identify on server.
VPN Configuration and connection standing
May you please assist me in understanding what’s the challenge. I will be actually grateful to you.
beneath is the code of the implementation.
closing class VPNManager {
let vpnManager = NEVPNManager.shared()
func initVPNTunnelProviderManager() {
self.vpnManager.loadFromPreferences { (error) -> Void in
self.checkVPNConfiguration()
if((error) != nil) {
print("VPN Preferences error: 1")
} else {
let IKEv2Protocol = NEVPNProtocolIKEv2()
IKEv2Protocol.username = "myusername"
IKEv2Protocol.serverAddress = "144.202.9.42" //server tunneling Handle
IKEv2Protocol.remoteIdentifier = "securevpn.com.myserver" //Distant id
IKEv2Protocol.localIdentifier = nil //Native id
IKEv2Protocol.deadPeerDetectionRate = .low
IKEv2Protocol.authenticationMethod = .none
IKEv2Protocol.useExtendedAuthentication = true //if you're utilizing sharedSecret technique then make it false
IKEv2Protocol.disconnectOnSleep = false
//Set IKE SA (Safety Affiliation) Params...
IKEv2Protocol.ikeSecurityAssociationParameters.encryptionAlgorithm = .algorithmAES256
IKEv2Protocol.ikeSecurityAssociationParameters.integrityAlgorithm = .SHA256
IKEv2Protocol.ikeSecurityAssociationParameters.diffieHellmanGroup = .group14
IKEv2Protocol.ikeSecurityAssociationParameters.lifetimeMinutes = 1440
//IKEv2Protocol.ikeSecurityAssociationParameters.isProxy() = false
//Set CHILD SA (Safety Affiliation) Params...
IKEv2Protocol.childSecurityAssociationParameters.encryptionAlgorithm = .algorithmAES256
IKEv2Protocol.childSecurityAssociationParameters.integrityAlgorithm = .SHA256
IKEv2Protocol.childSecurityAssociationParameters.diffieHellmanGroup = .group14
IKEv2Protocol.childSecurityAssociationParameters.lifetimeMinutes = 1440
let kcs = KeychainService()
//Save password in keychain...
kcs.save(key: "VPN_PASSWORD", worth: "hSyeI1H8Wsybb5qDk5abBrJ7LCu3bPbJrax9aFG77FiiJZu3eUepLwvg9pjjEL3")
//Load password from keychain...
IKEv2Protocol.passwordReference = kcs.load(key: "VPN_PASSWORD")
self.vpnManager.protocolConfiguration = IKEv2Protocol
self.vpnManager.localizedDescription = "Quilr VPN Configuration"
self.vpnManager.isEnabled = true
self.vpnManager.isOnDemandEnabled = true
//print(IKEv2Protocol)
//Set guidelines
var guidelines = [NEOnDemandRule]()
let rule = NEOnDemandRuleConnect()
rule.interfaceTypeMatch = .any
guidelines.append(rule)
print("SAVE TO PREFERENCES...")
//SAVE TO PREFERENCES...
self.vpnManager.saveToPreferences(completionHandler: { (error) -> Void in
if((error) != nil) {
print("VPN Preferences error: 2")
} else {
print("CALL LOAD TO PREFERENCES AGAIN...")
//CALL LOAD TO PREFERENCES AGAIN...
self.vpnManager.loadFromPreferences(completionHandler: { (error) in
if ((error) != nil) {
print("VPN Preferences error: 2")
} else {
var startError: NSError?
do {
//START THE CONNECTION...
attempt self.vpnManager.connection.startVPNTunnel()
} catch let error as NSError {
startError = error
print(startError.debugDescription)
} catch {
print("Deadly Error")
fatalError()
}
if ((startError) != nil) {
print("VPN Preferences error: 3")
//Present alert right here
print("title: Oops.., message: One thing went fallacious whereas connecting to the VPN. Please attempt once more.")
print(startError.debugDescription)
} else {
//self.VPNStatusDidChange(nil)
print("Beginning VPN...")
//START THE CONNECTION...
self.vpnConnectionStatusChanged()
}
}
})
}
})
}
}
}
func checkVPNConfiguration() {
let isVPNInstalled = vpnManager.isOnDemandEnabled || vpnManager.isEnabled || (vpnManager.protocolConfiguration != nil)
if isVPNInstalled {
print("VPN configuration is put in on the gadget.")
} else {
print("VPN configuration shouldn't be put in on the gadget.")
}
}
//MARK:- Join VPN
static func connectVPN() {
VPNManager().initVPNTunnelProviderManager()
}
//MARK:- Disconnect VPN
static func disconnectVPN() {
VPNManager().vpnManager.connection.stopVPNTunnel()
}
func vpnConnectionStatusChanged() {
let standing = self.vpnManager.connection.standing
print("VPN connection standing = (standing)")
change standing {
case NEVPNStatus.related:
print("related")
case NEVPNStatus.invalid, NEVPNStatus.disconnected :
print("disconnected")
case NEVPNStatus.connecting , NEVPNStatus.reasserting:
print("connecting")
case NEVPNStatus.disconnecting:
print("disconnecting")
default:
print("Unknown VPN connection standing")
}
}
}