Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 9 SimpleTunnel sample - Starting a new tunnel

I am trying hard to follow the example of SimpleTunnel given by Apple. I try to track how they make the customized call. However I cannot link the relationship between the connect button action with starting a new tunnel.

I tried to track it with PacketTunnelProvider but without success. I know they are override classes. I cannot find the point where the whole VPN connection starts.

My goal is to create a SSL VPN tunnel.

like image 786
FiFifi Avatar asked Feb 10 '23 01:02

FiFifi


2 Answers

After asking Apple and a few trial and error, I can finally trigger the extension part.

Prerequisite: (Network Extension permission)

  1. Add a new target -> Packet Tunnel Provider
  2. Trigger the extension by

    NEVPNConnection *conn = [manager connection];

    NSError *connError;

    [conn startVPNTunnelWithOptions:settingsDict andReturnError:&connError];

  3. Debug with the following steps

    (1) Build & run the app (2) Stop the app (3) Debug > attach to process by PID or name > Enter "PacketTunnel" (4) Start the app from your iPhone screen and you can debug for the extension

Hope the small steps I experienced can help the others to start. However, there are more upcoming questions and I need to check!

like image 148
FiFifi Avatar answered Feb 23 '23 00:02

FiFifi


The sample application and Packet Tunnel provider runs as a separate process. sample application is called as container app and the packet tunnel provider runs as app extension. These two components uses IPC for communication.

In sample application whenever connect toggle button is enabled startVPNTunnel() API will be called and the OS starts the packet tunnel provider which in turn calls your overrided method startTunnelWithOptions(). So this is where you start your connection to the VPN server. To answer your question link the connect action to a method that invokes startVPNTunnel() which in turn triggers packet tunnel provider. You cannot directly invoke start packet tunnel provider without the container application. Same gets applied to stop your VPN tunnel

Hope this answer helps you

like image 39
Ashok Avatar answered Feb 23 '23 00:02

Ashok