Andy Burnelli
2023-03-29 19:14:10 UTC
*How can we programmatically distinguish between a failed VPN*
*connection attempt versus a successful VPN connection?*
This is a general purpose solution _everyone_ can use instantly.
For free. To connect to any one of _thousands_ of free VPN servers.
Around the world. Perfectly legally. Maintained by a university in Japan.
All the necessary free vpn files are provided in the request below
such that anyone can test it out fully to use thousands of vpn servers.
*The question is what's a reliable test of whether the connection worked*
*or failed, so that the script can either sit still on the current vpn*
*server (if successful) or move to the next vpn server (if it failed)?*
Please *focus on the _technical_ question* (and not on the merits of VPN!)
(see explanation why in the sig)
The technical question is aimed to find a way to programmatically determine
either a failed VPN connection - or - vice versa - if necessary - to
determine success).
There is a batch question below but everything is testable since it's my
goal is a generic solution that _everyone_ can use at this very moment
and for years to connect to thousands of free VPNs around the world.
I've been using this process for years - where my question below is
simply to ask experts who know Windows batch better than I do, for
help in streamlining a _test_ to see if we're connected, or not.
All you need to test this is any openvpn client & the text config files.
Nothing else is needed.
Here's just one openvpn client (but any openvpn client should work).
<https://openvpn.net/community-downloads/>
<https://swupdate.openvpn.org/community/releases/OpenVPN-2.6.2-I001-amd64.msi>
Almost any openvpn configuration file should work, so here's just one
site that provides configs for thousands of rotating openvpn servers:
<http://vpngate.net> (username=vpn, password=vpn)
The only files you need from that web site are the links at the 7th column
which are listed as "OpenVPN Config file", each of which is uniquely named.
While some of these free vpn server configuration files last for months,
others go stale in just weeks or days (reasons explained at that web site).
Hence, I refresh my cache of thousands of free VPN servers periodically.
To connect to any given free openvpn server, I run the following batch
(which requires administrative permission to change the routing table):
set vpncmd=C:\the\path\to\openvpn\bin\openvpn.exe
set configdir=C:\the\path\to\the\config-files\config\
cd %configdir%
set vpnserver=219.100.37.1.ovpn
set vpnserver=219.100.37.2.ovpn
set vpnserver=219.100.37.3.ovpn
"%vpncmd% %configdir%%vpnserver%
The actual LIFO script is slightly more complex (as it skips UAC requests
and it adds the username & password to the VPN file and I delete the last
IP address after each run if it fails, etc.) but that's the fundamental
essence of what the script does to test a single openvpn configuration.
Since I'm deleting the last configuration file if/when it fails to connect,
the next configuration file will be the penultimate configuration file.
First it tries 219.100.37.3.ovpn
If that fails, I delete that line manually
Second it tries 219.100.37.2.ovpn
If that fails, I delete that line manually
Third it tries 219.100.37.1.ovpn
Where I repeat this process manually until I get a good connection.
This works for a list of thousands of files, but what would be more
efficient is to not have to _manually_ delete the failed configuration
files from the script itself after each failed connection attempt.
Hence the fundamental batch file question of...
*How can we programmatically distinguish between*
*a failed versus a successful VPN connection attempt?*
The question is what _test_ can I run inside that batch file to
automatically skip to the next configuration file if any one fails?
Something like this:
set vpngatefile=219.100.37.3
"%vpngatecmd% %vpngatedir%%vpngatefile%
if that fails, then set vpngatefile=219.100.37.2
"%vpngatecmd% %vpngatedir%%vpngatefile%
if that fails, then set vpngatefile=219.100.37.1
etc.
I'm aware of a "curl icanhazip.com" will show the same IP address for
a working connection but I do not wish to abuse their kind server.
Hence...
The question is what's a reliable test of whether the connection worked
or failed, so that the script can either sit still on the current vpn
server (if successful) or move on to the next vpn server (if it failed)?
*connection attempt versus a successful VPN connection?*
This is a general purpose solution _everyone_ can use instantly.
For free. To connect to any one of _thousands_ of free VPN servers.
Around the world. Perfectly legally. Maintained by a university in Japan.
All the necessary free vpn files are provided in the request below
such that anyone can test it out fully to use thousands of vpn servers.
*The question is what's a reliable test of whether the connection worked*
*or failed, so that the script can either sit still on the current vpn*
*server (if successful) or move to the next vpn server (if it failed)?*
Please *focus on the _technical_ question* (and not on the merits of VPN!)
(see explanation why in the sig)
The technical question is aimed to find a way to programmatically determine
either a failed VPN connection - or - vice versa - if necessary - to
determine success).
There is a batch question below but everything is testable since it's my
goal is a generic solution that _everyone_ can use at this very moment
and for years to connect to thousands of free VPNs around the world.
I've been using this process for years - where my question below is
simply to ask experts who know Windows batch better than I do, for
help in streamlining a _test_ to see if we're connected, or not.
All you need to test this is any openvpn client & the text config files.
Nothing else is needed.
Here's just one openvpn client (but any openvpn client should work).
<https://openvpn.net/community-downloads/>
<https://swupdate.openvpn.org/community/releases/OpenVPN-2.6.2-I001-amd64.msi>
Almost any openvpn configuration file should work, so here's just one
site that provides configs for thousands of rotating openvpn servers:
<http://vpngate.net> (username=vpn, password=vpn)
The only files you need from that web site are the links at the 7th column
which are listed as "OpenVPN Config file", each of which is uniquely named.
While some of these free vpn server configuration files last for months,
others go stale in just weeks or days (reasons explained at that web site).
Hence, I refresh my cache of thousands of free VPN servers periodically.
To connect to any given free openvpn server, I run the following batch
(which requires administrative permission to change the routing table):
set vpncmd=C:\the\path\to\openvpn\bin\openvpn.exe
set configdir=C:\the\path\to\the\config-files\config\
cd %configdir%
set vpnserver=219.100.37.1.ovpn
set vpnserver=219.100.37.2.ovpn
set vpnserver=219.100.37.3.ovpn
"%vpncmd% %configdir%%vpnserver%
The actual LIFO script is slightly more complex (as it skips UAC requests
and it adds the username & password to the VPN file and I delete the last
IP address after each run if it fails, etc.) but that's the fundamental
essence of what the script does to test a single openvpn configuration.
Since I'm deleting the last configuration file if/when it fails to connect,
the next configuration file will be the penultimate configuration file.
First it tries 219.100.37.3.ovpn
If that fails, I delete that line manually
Second it tries 219.100.37.2.ovpn
If that fails, I delete that line manually
Third it tries 219.100.37.1.ovpn
Where I repeat this process manually until I get a good connection.
This works for a list of thousands of files, but what would be more
efficient is to not have to _manually_ delete the failed configuration
files from the script itself after each failed connection attempt.
Hence the fundamental batch file question of...
*How can we programmatically distinguish between*
*a failed versus a successful VPN connection attempt?*
The question is what _test_ can I run inside that batch file to
automatically skip to the next configuration file if any one fails?
Something like this:
set vpngatefile=219.100.37.3
"%vpngatecmd% %vpngatedir%%vpngatefile%
if that fails, then set vpngatefile=219.100.37.2
"%vpngatecmd% %vpngatedir%%vpngatefile%
if that fails, then set vpngatefile=219.100.37.1
etc.
I'm aware of a "curl icanhazip.com" will show the same IP address for
a working connection but I do not wish to abuse their kind server.
Hence...
The question is what's a reliable test of whether the connection worked
or failed, so that the script can either sit still on the current vpn
server (if successful) or move on to the next vpn server (if it failed)?
--
Every Usenet question with the keyword VPN in it seems to always instigate
a plethora of trolls who tell us how dangerous it is to rely on VPN. Please
do not do that as this question isn't a philosophical question of the
merits of VPN or of the merits of privacy or even of the merits of free VPN
services (we all know everything you could possibly pontificate on that
subject so you will only be trolling us if you try to steer us from VPN).
Every Usenet question with the keyword VPN in it seems to always instigate
a plethora of trolls who tell us how dangerous it is to rely on VPN. Please
do not do that as this question isn't a philosophical question of the
merits of VPN or of the merits of privacy or even of the merits of free VPN
services (we all know everything you could possibly pontificate on that
subject so you will only be trolling us if you try to steer us from VPN).