如何在 MAC 中以编程方式设置 VPN 连接?
经过一段时间的搜索,我发现在 mac 中以编程方式建立 VPN 连接的唯一最佳来源是
http://lists.apple.com/archives/Macnetworkprog/2011/May/msg00032.html
但我很震惊编码时的第五点是关于 kSCNetworkProtocolTypePPP 的,但没有这样的事情......
有人做到了,如上面的链接所示 或者还有其他可用的来源吗...?
after searching for a while i found that the only best source available to establish a vpn connection programmatically in mac is at
http://lists.apple.com/archives/Macnetworkprog/2011/May/msg00032.html
but i was struck at the 5th point while coding which says about kSCNetworkProtocolTypePPP and there is no such thing...
has anybody done it as shown in the above link
or is there any other source available...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不需要获取 PPP 协议,您可以将设置直接应用到您创建的界面。如果您创建了这样的界面:
您可以直接使用 PPP 选项:
您必须使用以下方式应用共享密钥
如果您想启用“通过 VPN 发送所有流量”,您需要通过以下方式应用这些设置:首先获取 IPv4 协议:
此答案中提到的源代码提取自 https://github.com/halo/macosvpn/blob/master/macosvpn/Classes/VPNController.m 您可以在其中找到完整内容。
There is no need to fetch the PPP protocol, you can apply the settings directly to the interface you created. If you created the interface like this:
you can apply the PPP options directly using:
You'll have to apply the shared secret using
And if you want to enable "Send all traffic over VPN", you'll need to apply those settings by fetching the IPv4 protocol first:
The source code mentioned in this answer was extracted from https://github.com/halo/macosvpn/blob/master/macosvpn/Classes/VPNController.m where you can find it in its entirety.