PacketTunnelProvider Simple tunnel not work

Hi everyone,

First of all thanks to read me. Currently, I'm playing with the sample of tunnel provided by Apple and refactorized by community (because the Apple example is in swift 2 or maybe 3).

Here you could find the repo: https://github.com/networkextension/SimpleTunnel

After connect with my local server in my Mac, I tried to surf by internet, but I cannot.

Seems like traffic is not redirected to internet.

Any ideas?

Thanks for your time in advance

After connect with my local server in my Mac, I tried to surf by internet, but I cannot. Seems like traffic is not redirected to internet.

Okay, several things could be happening here; first, you are correct, your traffic could not be getting claimed for Safari. If that is the case, how is your NEPacketTunnelProvider setup here?

Next, if your traffic is getting claimed, then possibly it is not being read / parsed / written properly to and from the NEPacketTunnelFlow? This is the next place I would check.

Lastly, your tunnel may be failing to start altogether. If this is the case setup a NEVPNStatus observer to checkout the state of the tunnel.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

@matt, thanks for the support :)

The configuration for packet tunnel is that:

protocolConfiguration
    type = plugin
    identifier = 7FCF645B-4707-42AE-BFB9-76903115D4F5
    serverAddress = x.x.x.x:PORT // This is IP:PORT FORMAT
    identityDataImported = NO
    disconnectOnSleep = NO
    disconnectOnIdle = NO
    disconnectOnIdleTimeout = 0
    disconnectOnWake = NO
    disconnectOnWakeTimeout = 0
    includeAllNetworks = NO
    excludeLocalNetworks = YES
    enforceRoutes = NO
    pluginType = bundleIdentifier of the app that contains the extension
    authenticationMethod = 0
    reassertTimeout = 0

And the code of the start tunnel

override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {

		let newTunnel = ClientTunnel()

		newTunnel.delegate = self

		if let error = newTunnel.startTunnel(self) {
			completionHandler(error as NSError)
		} else {

			// Save the completion handler for when the tunnel is fully established.
			pendingStartCompletion = completionHandler
			tunnel = newTunnel
		}
	}

And the VPNStatus is .connected

My ClientTunnelConnection receive packets.

The connection to tunnel seems to be ok:

    parameters = {
        processUUID = A22C0610-214E-3C0F-9ABB-DDEB02351D12
        effectiveProcessUUID = A22C0610-214E-3C0F-9ABB-DDEB02351D12

        pid = 1153
        uid = 501

        protocolTransforms = (
        )
        ipProtocol = 6
    }

    endpoint = { IP:PORT // Owned by server
    }
}

:(.

Why there's no simple tunnel example of Apple updated to the latest version of Xcode and Swift?

serverAddress = x.x.x.x:PORT // This is IP:PORT FORMAT

Remove the port, you do not need this here.

Unfortunately the example you provided does not provide clues on what may be going wrong here as far a your NEIPv4Route / NEIPv6Route or you NEIPv4Settings / NEIPv6Settings. Now, if you tunnel is getting packets then you must be claiming some traffic, and if you are able to parse these packets from NEPacketTunnelFlow and verify that they are Safari packets then you should be set here. From there, you would need to setup a provider transport to send these packets to your VPN server.

Regarding:

Why there's no simple tunnel example of Apple updated to the latest version of Xcode and Swift?

I understand, if you need further help with this then open a TSI and I can take a look at your project. I work off an Objective-C based project that I use for testing, but translating it to Swift is should be fairly straight forward.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
PacketTunnelProvider Simple tunnel not work
 
 
Q