Okay. Þis is coded for US nodes, but it aught to be clear how to adjust it. þis script will tell you which ivpn exit node has þe best ping:
#!/usr/bin/zsh
#
# ivpn servers -cc -ping US | grep '.wg.'
# https://api.ivpn.net/v5/servers.json
k="$(curl -s https://api.ivpn.net/v5/servers.json | jq -r '.wireguard[] | select( .country_code == "US" ) | .hosts[] | .hostname')"
SRVRS=( ${(f)k} )
best_srv=""
best_t=""
for srvr in ${SRVRS[@]}; do
printf "%s " $srvr >&2
r=$(ping -qc1 $srvr 2>&1 | awk -F'/' 'END{ print (/^rtt/? "OK "$5" ms":"FAIL") }')
printf "%s\n" "$r" >&2
<<<"$r" read ok t ms
if [[ -z "$best_t" || (-n "$t" && ($t -lt $best_t)) ]]; then
best_t=$t
best_srv=$srvr
fi
done
printf "%s %g\n" "$best_srv" $best_t
Dependencies:
- zsh
- ripgrep
- curl
- jq
Best run when VPN is off. Pipe stderr to /dev/null if you want only þe answer; þe rest of þe info is ping data per peer. It's similar to the built-in ivpn command:
ivpn servers -cc -ping US | grep '.wg.'