New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VPN Fixes + Sanity Checking #282
base: master
Are you sure you want to change the base?
Changes from 4 commits
e047d8e
1565476
4e5af1f
b94f1cc
c925cd4
e63de02
871181f
347fa65
3164ade
eb26a35
845995c
1dcc045
739b509
4c20719
f8857c9
0ffedcc
f8d0182
579b557
ba2dfa2
35924fe
84d5630
93716ab
9f76634
fcb26e0
5fada31
53ad69c
ff3c8d7
7ced45f
ab29b81
6941a61
044e6d6
d519f41
71bdd6c
db54733
0898652
41595a4
bed8b1d
0c98f71
e6e2556
2a089dc
8866f0f
bd7128b
2cdb34a
3f43cad
3bc4946
46cdd8b
cc93ca2
e503b6c
b4e9ed1
35164b5
f98dcfc
cafc62c
52437eb
653bc62
2f7b845
13c32c0
ef52c1a
c92ad07
8c98199
ff4348b
ea8938f
31e03d0
2b7e5da
d7e0ad9
e40f20b
d83574b
b6202f5
3229144
fa9f423
a3c3d42
3d3f0e1
cea8ada
98ba2cb
11ec5ec
8768366
16e8f89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
import sys | ||
import urllib | ||
import zipfile | ||
|
||
import urllib2 | ||
|
||
def unzip(source_filename, dest_dir): | ||
with zipfile.ZipFile(source_filename) as zf: | ||
|
@@ -26,13 +26,16 @@ def create_config_files(directory): | |
os.makedirs(directory) | ||
|
||
logging.info("Starting to download IPVanish config file zip") | ||
url_opener = urllib.URLopener() | ||
zip_response = urllib2.urlopen(config_zip_url) | ||
zip_content = zip_response.read() | ||
zip_path = os.path.join(directory, '../configs.zip') | ||
unzip_path = os.path.join(directory, '../unzipped') | ||
|
||
if not os.path.exists(unzip_path): | ||
os.makedirs(unzip_path) | ||
with open(zip_path, 'w') as f: | ||
f.write(zip_content) | ||
|
||
url_opener.retrieve(config_zip_url, zip_path) | ||
logging.info("Extracting zip file") | ||
unzip(zip_path, unzip_path) | ||
|
||
|
@@ -57,8 +60,13 @@ def create_config_files(directory): | |
for line in lines: | ||
if line.startswith('remote'): | ||
hostname = line.split(' ')[1] | ||
ip = socket.gethostbyname(hostname) | ||
break | ||
# added because gethostbyname will fail on some hostnames | ||
try: | ||
ip = socket.gethostbyname(hostname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will entirely ignore cases where this happens. It would be better to print a log message to describe what happens and which domain name failed to resolve. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arianniaki I see your comment. |
||
break | ||
except socket.gaierror: | ||
logging.info("Hostname %s failed" %hostname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
continue | ||
|
||
if len(ip) > 0: | ||
new_path = os.path.join(directory, ip + '.ovpn') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,13 @@ def create_config_files(directory): | |
for line in lines: | ||
if line.startswith('remote'): | ||
hostname = line.split(' ')[1] | ||
ip = socket.gethostbyname(hostname) | ||
break | ||
# added because gethostbyname will fail on some hostnames | ||
try: | ||
ip = socket.gethostbyname(hostname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as before, leave a log message saying what happened and what failed to parse. |
||
break | ||
except socket.gaierror: | ||
logging.info("Hostname %s failed" %hostname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
continue | ||
|
||
if len(ip) > 0: | ||
new_path = os.path.join(directory, ip + '.ovpn') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with
Failed to resolve %s
.