mozilla-vpn-client
mozilla-vpn-client copied to clipboard
VPN-4979: (part 1) iOS network extension health checks
Description
Important: This PR adds a new git submodule, SwiftyPing. It didn't seem to make sense to roll our own ping sender, and this code seems clean to me (and uses the MIT license).
I'm breaking down VPN-4979 into 3 PRs, to be stacked on one another:
- This one, which adds health monitoring
- One that adds silent server switching in. It's going to refactor a little bit of how it's done for Android so the code can be shared, and if we're trying to keep PRs small it should be a separate one.
- One that adds the telemetry in. It should be done after https://github.com/mozilla-mobile/mozilla-vpn-client/pull/9057 is merged, as it will be based on those new metrics.
The app and the Android daemon do health checks differently:
- Desktop: Sending pings out basically constantly. Health check every second based on the last 32 pings.
- Android daemon: Sending out a check every 30 seconds. Sees what it gets back from those pings, and makes a health decision based on which pings are reached.
Since we want to be respectful of device battery life, we need to carefully balance "not sending out too many checks" with "don't leave the device in a messed up state". This PR sends out 20 pings every 15 seconds, and calculates health status based on that.
We don't currently have iOS testing infrastructure, so not adding tests for this.
Reference
VPN-4979
Checklist
- [x] My code follows the style guidelines for this project
- [x] I have not added any packages that contain high risk or unknown licenses (GPL, LGPL, MPL, etc. consult with DevOps if in question)
- [x] I have performed a self review of my own code
- [x] I have commented my code PARTICULARLY in hard to understand areas
- [x] I have added thorough tests where needed