Thanks for your comment mate,
Thanks to it, I tested running the script while making a Zoom call earlier today. The call froze for ~15-20 seconds, then resumed (once OpenVPN restarted, and then some more I suppose). I don't do a lot of video chats / streaming, so doing the crontab thing works in my use case just fine.
In this case, maybe running a script from /etc/rc.local
might be useful - besides a watchdog checking for failed connection like in NordVPN's tutorial, it might be useful to check the average ping round trip speeds. I wrote a quick script for that:
#!/bin/sh
# Ping N times
N=10
# Upper Bound for round-trip average
UB=120
while sleep 50; do
# ping in quiet mode for N times,
# grab last raw and evaluate if the avg. round trip took longer then expected
T=$(ping -qc "$N" 1.1.1.1 | awk -F '\/' -v UB=$UB '/round-trip/{print ($4+0)<=UB}')
if [ "$T" -eq 0 ]; then
/root/vpn-profile-switcher.sh
fi
done
I haven't tried it out yet, and I suppose it might be better implemented when combined with NordVPN's (simplistic) watchdog at the bottom of their tutorial. Maybe something a bit more elaborate in the style of this watchdog is more appropriate.
I do think the automatic profile switching script needs a few other functions built in to it, such as:
- Checking if the server currently connected is between the first few result of the recommended servers and what is the load on each of those first few recommended servers.
- Saving more then one profile, so I could always be able to switch to a known good server.
- Switch to the last known good server, or to a specified known-to-be-good one.
- Check if JQ is installed, and if so forgo using an intermediary for checking for good group + country combinations (by creating a local db, like I set up to be done by a Github action).