apple icon indicating copy to clipboard operation
apple copied to clipboard

TunnelKit: Don't disconnect when network goes down

Open roop opened this issue 4 years ago • 4 comments

This is a proof-of-concept that shows how TunnelKit can be modified to keep the tunnel process running when the network goes down, and wait for the network to come back up. The tunnel process uses NWPathMonitor to figure out when the network is back.

Consequently, connect on demand is turned off.

Being a draft PR, this only modifies the in-repo version of TunnelKit. The Podfile is unchanged.

roop avatar May 15 '20 21:05 roop

@roop I added my commit on a branch with the same name as on this repository. Can you pick that commit up in your branch? Should be a matter of resetting your branch to the origin one with the same name.

jeroenleenarts avatar May 18 '20 19:05 jeroenleenarts

The eduVPN/apple:tunnelkit_keep_tunnel_when_network_is_down branch had a couple of other commits not related to this PR, which I did not pick up.

roop avatar May 19 '20 06:05 roop

Nice work, I only wonder how quick network change detection is done by NWPathMonitor (I assume it's instant though..), we might have to add fire-walling to prevent data leaking after a network comes available and before a reconnection is triggered. The OS probably takes care of it as soon as startTunnel is called, but I can imagine there is some time between when a network comes up and the detection of it by NWPathMonitor. I will test this and let know.

joosth9n avatar May 19 '20 12:05 joosth9n

@joosthoogendoorn NWPathMonitor's detection takes a good number of seconds -- it's not instant. With this PR, the tunnel doesn't go down and up even if the link goes down and up -- the tunnel is "reasserting" while the link is down. The OS does not call stopTunnel / startTunnel during this time. As far as I know, there's no data leak.

roop avatar May 20 '20 17:05 roop