ios - 使用 NEVPNManager 的 IPSec VPN 在睡眠时不会断开连接
问题描述
我正在为 macOS 开发 IPSec VPN 解决方案。我设法通过 NEVPNManager 安装了 VPN 配置,一切正常。除了,我的要求是在 mac 进入睡眠状态时断开 VPN。下面是我正在使用的 IPSec 配置文件。
- (void)setupIPSec
{
[self configVPNKeychain];
NSData *passwordData = [self persistentReferenceForSavedPassword:@"username" service:kPasswordReference account:@"account" description:@"login"];
NSData *sharedSecretData = [self persistentReferenceForSavedPassword:@"54343333" service:kSharedSecretReference account:@"account" description:@"IPSec Shared Secret"];
// config IPSec protocol
NEVPNProtocolIPSec *p = [[NEVPNProtocolIPSec alloc] init];
p.username = @"username012134";
p.serverAddress = @"ipsec.route.com";
// get password persistent reference from keychain
p.passwordReference = passwordData;
p.authenticationMethod = NEVPNIKEAuthenticationMethodSharedSecret;
p.sharedSecretReference = sharedSecretData;
p.useExtendedAuthentication = YES;
p.disconnectOnSleep = YES; // This is were I am setting YES to disconnect the VPN connection when on Sleep.
[NEVPNManager sharedManager].enabled = YES;
[NEVPNManager sharedManager].protocolConfiguration = p;
[NEVPNManager sharedManager].localizedDescription = @"VPN";
}
任何人都可以请指导我。
解决方案
推荐阅读
- node.js - NodeJs + MongoDB:通过it参数返回文档
- docker - 如何在不重新创建新容器的情况下添加 docker 磁盘空间?
- python - 使用子进程通过 Flask 运行命令抛出 KeyError: 'PWD'
- javascript - 将字幕动态加载到视频中
- c# - 将自定义对象序列化为 .NET 中的基元
- android - 在前台服务中扫描 BLE 设备
- python - Python:Tkinter 滞后
- python - 回归一个元素 BeautifulSoup
- java - 无法使用 ari4java 库创建 Asterisk Stasis App
- vue.js - 构建项目时在 Vue.js 中找不到相关模块