NEVPNManager规则自动断开连接

时间:2018-09-19 16:47:22

标签: ios objective-c swift nevpnmanager

我有一个NEVPNProtocolIKEv2连接。如何配置规则,以便10分钟后断开连接?

        let providerManagerIKEv2 = NEVPNProtocolIKEv2()
        providerManagerIKEv2.authenticationMethod = NEVPNIKEAuthenticationMethod.sharedSecret
        providerManagerIKEv2.serverAddress = "ip address"
        providerManagerIKEv2.disconnectOnSleep = false
        providerManagerIKEv2.deadPeerDetectionRate = NEVPNIKEv2DeadPeerDetectionRate.medium
        providerManagerIKEv2.sharedSecretReference = KeychainWrapper.standard.dataRef(forKey: "sharedSecretIKEv2")
        providerManagerIKEv2.disableMOBIKE = false
        providerManagerIKEv2.disableRedirect = false
        providerManagerIKEv2.enableRevocationCheck = false
        providerManagerIKEv2.enablePFS = false
        providerManagerIKEv2.useExtendedAuthentication = true
        providerManagerIKEv2.useConfigurationAttributeInternalIPSubnet = false

        providerManagerIKEv2.remoteIdentifier = DataManager.sharedInstance.configServer.remoteID
        providerManagerIKEv2.localIdentifier = DataManager.sharedInstance.configServer.localID
        providerManagerIKEv2.username = DataManager.sharedInstance.configServer.username
        providerManagerIKEv2.passwordReference = KeychainWrapper.standard.dataRef(forKey: "password")

        self.loadProfileIKEv2 { _ in
            self.manager.protocolConfiguration = providerManagerIKEv2
            self.manager.onDemandRules = [NEOnDemandRuleConnect()]
            self.manager.isOnDemandEnabled = false
            self.manager.isEnabled = true
            self.manager.localizedDescription = "VPN"
}

0 个答案:

没有答案