HomeiOS Developmentios - Established the VPN Connection for community sniffer

ios – Established the VPN Connection for community sniffer


We’re attempting to determine the reference to VPN for monitoring the community actions.
I can get the url however my web isn’t working. After I begin set up the connection it reveals that connection is in connecting mode. However after someday connection could be disconnected. The given beneath code for set up the connection:

non-public func join(choices: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
    let settings: NEPacketTunnelNetworkSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: proxyServerAddress)
    
    /* proxy settings */
    let proxySettings: NEProxySettings = NEProxySettings()
    proxySettings.httpServer = NEProxyServer(
        deal with: proxyServerAddress,
        port: Int(proxyServerPort)
    )
    proxySettings.httpsServer = NEProxyServer(
        deal with: proxyServerAddress,
        port: Int(proxyServerPort)
    )
    proxySettings.autoProxyConfigurationEnabled = false
    proxySettings.httpEnabled = true
    proxySettings.httpsEnabled = true
    proxySettings.excludeSimpleHostnames = true
    proxySettings.exceptionList = [
        "192.168.0.0/16",
        "10.0.0.0/8",
        "172.16.0.0/12",
        "127.0.0.1",
        "localhost",
        "*.local"
    ]
    settings.proxySettings = proxySettings
    
    /* ipv4 settings */
    let ipv4Settings: NEIPv4Settings = NEIPv4Settings(
        addresses: [settings.tunnelRemoteAddress],
        subnetMasks: ["255.255.255.255"]
    )
    ipv4Settings.includedRoutes = [NEIPv4Route.default()]
    ipv4Settings.excludedRoutes = [
        NEIPv4Route(destinationAddress: "192.168.0.0", subnetMask: "255.255.0.0"),
        NEIPv4Route(destinationAddress: "10.0.0.0", subnetMask: "255.0.0.0"),
        NEIPv4Route(destinationAddress: "172.16.0.0", subnetMask: "255.240.0.0")
    ]
    settings.ipv4Settings = ipv4Settings
    
    let dnsSettings = NEDNSSettings(servers: ["8.8.8.8", "1.1.1.1"])
    settings.dnsSettings = dnsSettings
    
    /* MTU */
    settings.mtu = 1500
    
    
    RawSocketFactory.TunnelProvider = self

    self.setTunnelNetworkSettings(settings, completionHandler: { error in
        guard error == nil else {
            completionHandler(error)
            return
        }
        let newProxyServer = GCDHTTPProxyServer(deal with: IPAddress(fromString: self.proxyServerAddress),
        port: Port(port: self.proxyServerPort))
        self.proxyServer = newProxyServer
        do {
            completionHandler(nil)
        } catch let proxyError {
            completionHandler(proxyError)
        }
    })
    
    completionHandler(nil)
}

Log message when connection is being in course of:

2023-10-16T16:00:28+0530 data com.apple.nio-connect-proxy.ConnectHandler : channel=ObjectIdentifier(0x0000000103e0c570) localAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:8080) remoteAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:52889) [VPN] CONNECT gateway.icloud.com:443 HTTP/1.1
2023-10-16T16:00:28+0530 data com.apple.nio-connect-proxy.ConnectHandler : channel=ObjectIdentifier(0x0000000103e0c570) localAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:8080) remoteAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:52889) [VPN] Connecting to gateway.icloud.com:443
2023-10-16T16:00:30+0530 data com.apple.nio-connect-proxy.ConnectHandler : channel=ObjectIdentifier(0x0000000101a0bea0) localAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:8080) remoteAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:52890) [VPN] CONNECT cl3.apple.com:443 HTTP/1.1
2023-10-16T16:00:30+0530 data com.apple.nio-connect-proxy.ConnectHandler : channel=ObjectIdentifier(0x0000000101a0bea0) localAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:8080) remoteAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:52890) [VPN] Connecting to cl3.apple.com:443

Log message after the connection failed:

2023-10-16T16:02:21+0530 error com.apple.nio-connect-proxy.ConnectHandler : channel=ObjectIdentifier(0x000000010610d1e0) localAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:8080) remoteAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:52898) [VPN] Join failed: connectTimeout(NIOCore.TimeAmount(nanoseconds: 10000000000))
2023-10-16T16:02:28+0530 error com.apple.nio-connect-proxy.ConnectHandler : channel=ObjectIdentifier(0x000000010610a6f0) localAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:8080) remoteAddress=Non-obligatory([IPv4]127.0.0.1/127.0.0.1:52899) [VPN] Join failed: connectTimeout(NIOCore.TimeAmount(nanoseconds: 10000000000))

Can anybody assist me.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments