mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
Apple's [docs state](https://developer.apple.com/documentation/networkextension/nepackettunnelprovider/starttunnel(options:completionhandler:)#Discussion) that we should only call the PacketTunnelProvider's `completionHandler` once the tunnel is ready to route packets. Calling it prematurely, while shouldn't cause packets to get routed to us (we haven't added the routes yet), will however cause the system to think our VPN is "online", which disconnects other VPNs and communicates to the user Firezone is "connected". If the portal is then slow to send us the init, we will be stuck in this quasi-connected state for more than a brief moment of time. To fix this, we thread `completionHandler` through to `Adapter` and call this if we are configuring the tun interface for the first time. This way, we remain in the `connecting` state until the tunnel is fully configured.