On Tue, 26 Jan 2016 00:22:04 +0000, MWBradburne wrote:
> But, after having said all that above, I think it's easier to
> just tell wget to go to level 2 as I will explain next, which
> will download that ovpn file directly.
If I use your suggestion to just get everything up to level 2,
that downloads all the ovpn files automatically!
A. Run wget to download everything up to level 2:
$ mkdir /tmp/vpnget/
$ cd /tmp/vpnget/
$ wget -r -l 2
http://www.vpngate.net/en/
B. Notice you now have *all* the ovpn files!
$ cd /tmp/vpnget/
www.vpngate.net/common/
$ ls *93.48.253.169*
openvpn_download.aspx?sid=1453756386281&udp=1&host=93.48.253.169&port=50220&hid=2792973&%2Fvpngate_93.48.253.169_udp_50220.ovpn
$ ls *219.79.35.88*
openvpn_download.aspx?sid=1453756386281&tcp=1&host=219.79.35.88&port=443&hid=2634121&%2Fvpngate_219.79.35.88_tcp_443.ovpn
openvpn_download.aspx?sid=1453756386281&udp=1&host=219.79.35.88&port=1194&hid=2634121&%2Fvpngate_219.79.35.88_udp_1194.ovpn
Those are horribly named but perfectly valid *.ovpn files.
C. Add the fix for dns leaks:
#!/bin/bash
# fixovpn.sh adds three lines to all ovpn files in the directory to stop dns leaks
#
https://forum.vpn.ac/discussion/13/running-openvpn-in-linux-terminal-with-no-dns-leaks
# script-security 2
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
for filename in *.ovpn; do echo -e "script-security 2\nup /etc/openvpn/update-resolv-conf\ndown /etc/openvpn/update-resolv-conf" >> $filename; done
# WIP. Need to add a check not to do this twice if it's run by mistake a second time!
D. Make the file name a LOT shorter!
$ mv "openvpn_download.aspx?sid=1453756386281&udp=1&host=93.48.253.169&port=50220&hid=2792973&%2Fvpngate_93.48.253.169_udp_50220.ovpn" \
vpngate_93.48.253.169_udp_50220.ovpn
NOTE: I'm doing this step MANUALLY (yuck).
If you have a way of shortening the file names automatically, that would be
a nice improvement. All you need is the IP address because we can then run
the geolocation renaming step below.
E. Optionally, run a geolocation on that file based on the IP address.
NOTE: For consistency, this geolocation-renaming program assumes the
file name is the same as it would be had we manually right clicked on
the link at
vpngate.net to download the UDP IP-address ovpn file manually.
#!/bin/bash
# vpngeo.sh renames openvpn *.ovpn files based on their geolocation
lsfile=/tmp/lsovpn.txt
ipfile=/tmp/ipovpn.txt
opfile=/tmp/ipgeo.csv
shfile=/tmp/renameovpn.sh
ls *.ovpn > $lsfile
vi $lsfile
#####
# "lsfile" content is of the format:
# $ touch vpngate_76.64.65.32_udp_1519.ovpn
# $ touch vpngate_76.64.65.32_tcp_1519.ovpn
# $ touch vpngate_88.187.124.69_udp_1195.ovpn
# $ touch vpngate_104.238.116.222_udp_1194.ovpn
# $ touch vpngate_108.224.9.179_udp_1195.ovpn
#####
# strip out just the IP address from the *.ovpn file name
sed -e 's/^[^0-9,.]*//g' -e 's/_.*//g' $lsfile | sort -u -o $ipfile
vi $ipfile
#####
# "ipfile" content is of the format:
# 76.64.65.32
# 88.187.124.69
# 104.238.116.222
# 108.224.9.179
#####
# "opfile" content is of the format:
rm $opfile
for i in $( cat $ipfile ); do echo "$i,\"$( geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat $i | cut -d' ' -f4-99 )\""|sed -e 's/, /,/g' -e 's/ \+/-/g' >> $opfile; done
vi $opfile
rm $shfile
#####
# "opfile" content is of the format:
# 76.64.65.32,"Rev-1:-CA,N/A,N/A,N/A,N/A,43.642502,-79.387199,0,0"
# 88.187.124.69,"Rev-1:-FR,B8,Provence-Alpes-Cote-d'Azur,Menton,06500,43.803501,7.496100,0,0"
# 104.238.116.222,"Rev-1:-US,AZ,Arizona,Scottsdale,85260,33.611900,-111.890602,753,480"
# 108.224.9.179,"Rev-1:-US,CA,California,Garden-Grove,92843,33.754501,-117.946404,803,714"
#####
sed -e 's/\"Rev-1:-//g' -e 's/_ /_/g' -e 's/\///g' $opfile|tr -d "'"|awk -F, '{print "mv *"$1"* vpn_"$2"_"$4"_"$5"_"$1".ovpn"}' >> $shfile
vi $shfile
#####
# "shfile" content is of the format:
# mv *76.64.65.32* vpn_CA_NA_NA_76.64.65.32.ovpn
# mv *88.187.124.69* vpn_FR_Provence-Alpes-Cote-dAzur_Menton_88.187.124.69.ovpn
# mv *104.238.116.222* vpn_US_Arizona_Scottsdale_104.238.116.222.ovpn
# mv *108.224.9.179* vpn_US_California_Garden-Grove_108.224.9.179.ovpn
#####
chmod u+x $shfile
sh $shfile
exit 0
F. Now that the files have a short name, just run Marek's vpnrun on the directory!
$ vpnrun.sh
(which runs the following command, but gives you choices what do to if it fails):
$ sudo openvpn --config vpn_US_California_Garden-Grove_108.224.9.179.ovpn
I realize this process is ripe for improvement, but, since it would give
all of us easier access to freeware VPN servers, I post this for others
to benefit from.
I'm having trouble figuring out how to shorten the huge original file names
so that the geolocation program can rename them automatically, so, I'm doing
that ugly filename shortening step manually (yuck).