Following on from the above, I decided to have a look at the source-code to DietPi-VPN to see if I could figure out what it was doing, and a couple of things occurred to me, so I fired up the new 7.1 in a virtual machine. Sadly there are a couple of issues when setting up a ProtonVPN account.
With ProtonVPN, there are multiple levels of server access:
Free 0
Basic1
Plus 2
Visionary (but that is irrelevant to the VPN server choice)
When DietPi-VPN gets a list of the ProtonVPN servers in:
110 G_EXEC curl -sSfLO ‘https://api.protonvpn.ch/vpn/logicals’
It then parses the file by Domain to create a list of servers to connect to:
114 sed ‘s/“Domain”:"/\n/g’ logicals | mawk -F" ‘NR % 2 == 0 {print $1}’ > $FP_PROTONVPN_SERVERS
For example, if you look in https://api.protonvpn.ch/vpn/logicals at #318, which is the NL#25 server, you will see the server name is listed in the drop-down as [nl-25.protonvpn.com]. If you have a free account then you will not be able to connect to this server, as shown in the ‘Tier’ section it is 1 (Basic). Also in the ‘Features’ it has 4 - which indicates it allows P2P traffic, and in ‘Load’ it indicates the current server load in %.
So the problem with selecting a server from the dropdown, is that unless you are a Plus or Visionary subscriber, then you will be taking a random guess if you can connect to that server from a choice of 1200+ servers.
To give a meaningful list of servers to select, you would need to ask the user what subscription plan they have and parse the list by Tier<=plan. That would give a list of connectable servers, but still not indicate what that server is capable of offering (P2P, TOR over VPN), so ideally it should parse the Features number to indicate server features too. Ideally adding Load would give even more information. The ideal server list (imho) would look something like (if you were a Plus subsciber):
[NL#25 Basic P2P 73%]
[NL#26 Plus P2P 25%]
[UK#17 Basic 54%]
[US-FREE#1 Free 98%]
or (if you were a Basic subscriber):
[NL#25 Basic P2P 73%]
[UK#17 Basic 54%]
[US-FREE#1 Free 98%]
and (free user):
[US-FREE#1 Free 98%]
I haven’t been through the server list to see what all the Feature numbers equate to in relation to server features, but 0 is nothing extra and 4 is P2P. If there’s a need, I can work out the others. I’ve written a couple of GUI monitoring programs for the ProtonVPN CLI tool in the past, but have never worked with Bash scripts.