I've implemented a custom system extension VPN for macOS using Packet Tunnel Provider. The VPN is configured with on-demand, and a rule to always connect whenever there's traffic:
onDemandRules = [NEOnDemandRuleConnect()]
As for the tunnel's settings (at the Packet Tunnel Provider), I've configured a split tunnel, so some routes are excluded from the tunnel.
Now I have the following scenario:
- The VPN is connected
- The Mac enters sleep
- The sleep() function is called (at my Packet Tunnel Provider)
- The Mac briefly awakes to check emails/push notifications/etc. This traffic is excluded from the tunnel.
What is the expected behavior here? Should the wake function be called because of the on-demand rule? Or should the VPN remain asleep because this traffic is excluded from the tunnel?
I don’t think so.
I’ve not seen complaints about this from iOS developers, but that’s not super surprising. Both platforms have their own complexities when it comes to networking, and sometimes the ducks just don’t line up [1].
At the routing layer we recently introduced excludeAPNs
that can help with issues like this, but I’m not aware of anything like that at the on-demand layer. My suggestion is that you file an enhancement request for that. Please post your bug number, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] For an example of this, see this thread.