gpt4 book ai didi

iOS VPN 一段时间后自动断开连接

转载 作者:行者123 更新时间:2023-11-29 13:51:35 24 4
gpt4 key购买 nike

我正在开发一个 VPN 应用程序,VPN 工作正常,但在 15-20 分钟后,它会自动断开连接。这是我正在使用的配置

        let vpnProtocol = NEVPNProtocolIKEv2()
vpnProtocol.username = CredentialsManager.shared.accessToken
vpnProtocol.localIdentifier = CredentialsManager.shared.accessToken

print("VPN Connecting to \(self.region.name ?? "Error! Must be a valid region name!")")

if let region = self.region {
f
vpnProtocol.serverAddress = region.serverAddress
vpnProtocol.remoteIdentifier = region.serverAddress
}

let encodedIdentifier = "Secret Password".data(using: .utf8)!
let item = [kSecClass: kSecClassGenericPassword,
kSecAttrGeneric: encodedIdentifier,
kSecAttrAccount: encodedIdentifier,
kSecMatchLimit: kSecMatchLimitOne,
kSecReturnPersistentRef: kCFBooleanTrue as Any,
kSecAttrService: "XYZ"] as [CFString : Any]

var passwordReference: CFTypeRef?
SecItemCopyMatching(item as CFDictionary, &passwordReference)

vpnProtocol.passwordReference = passwordReference as? Data
vpnProtocol.authenticationMethod = .none
vpnProtocol.useExtendedAuthentication = true

vpnProtocol.ikeSecurityAssociationParameters.encryptionAlgorithm =
.algorithmAES256GCM
vpnProtocol.ikeSecurityAssociationParameters.integrityAlgorithm = .SHA384
vpnProtocol.ikeSecurityAssociationParameters.diffieHellmanGroup = .group14

vpnProtocol.childSecurityAssociationParameters.encryptionAlgorithm = .algorithmAES256GCM
vpnProtocol.childSecurityAssociationParameters.integrityAlgorithm = .SHA384
vpnProtocol.childSecurityAssociationParameters.diffieHellmanGroup = .group14

vpnProtocol.disconnectOnSleep = false

self.vpnManager.protocolConfiguration = vpnProtocol
let connectRule = NEOnDemandRuleConnect()
connectRule.interfaceTypeMatch = .any

self.vpnManager.onDemandRules = [connectRule]
self.vpnManager.isOnDemandEnabled = self.connectOnDemand
self.vpnManager.localizedDescription = "XYZ VPN"
self.vpnManager.isEnabled = true

请帮助我,如何确定导致自动断开连接的问题。

最佳答案

用这个改变你的VPN协议(protocol):NEVPNProtocolIPSec也许它会对你有所帮助。

关于iOS VPN 一段时间后自动断开连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59453611/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com