【问题标题】:How can I add a proxy configuration to a VPN?如何向 VPN 添加代理配置?
【发布时间】:2017-06-04 04:22:19
【问题描述】:

这是我用来通过我的应用添加 VPN 配置的一些示例代码。我的问题是,我怎样才能添加代理配置。在设置应用程序和 Apple Configurator 中,用户可以添加代理设置(自动或手动)以及他们的 VPN 设置。

以下是我找到的一些示例代码,但我也找不到任何关于如何添加代理的线索。

let manager = NEVPNManager.shared()
    manager.loadFromPreferences { (error) -> Void in
        if manager.protocolConfiguration  == nil {
            let newIPSec = NEVPNProtocolIKEv2()
            newIPSec.serverAddress = "mycompany.vpn"
            newIPSec.username = "myvpnusername"
            newIPSec.identityDataPassword = "myvpnpassword"
            newIPSec.authenticationMethod = NEVPNIKEAuthenticationMethod.none
            newIPSec.disconnectOnSleep = false

            manager.protocolConfiguration = newIPSec
            manager.isEnabled = true

            manager.saveToPreferences(completionHandler: { (error) -> Void in

            })
        }

【问题讨论】:

    标签: ios swift swift3 proxy nevpnmanager


    【解决方案1】:

    在调用 saveToPreferences 之前,只需添加以下内容:

    let proxy = NEProxySettings()
    proxy.autoProxyConfigurationEnabled = true
    proxy.proxyAutoConfigurationURL = URL(string: "url_of_proxy.pac")
    manager.protocolConfiguration.proxySettings = proxy
    

    【讨论】:

      猜你喜欢
      • 2011-09-07
      • 2016-02-22
      • 1970-01-01
      • 2015-04-14
      • 2013-09-13
      • 2021-11-24
      • 2022-01-08
      • 1970-01-01
      • 2012-07-06
      相关资源
      最近更新 更多