Skip to content
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

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
e047d8e
purevpn and ipvanish, getting ip addresses of vpns sometimes lead to …
arianniaki Jun 28, 2017
1565476
adding log info when gethostname fails
arianniaki Jun 30, 2017
4e5af1f
HMA vpn structure fixed to fetch updated config file
arianniaki Jun 30, 2017
b94f1cc
fixed fetching the configs file for ipvanish
arianniaki Jul 7, 2017
c925cd4
log messages modified for all vpn proxies
arianniaki Jul 11, 2017
e63de02
log messages fixed
arianniaki Jul 11, 2017
871181f
Initial changes for sanity check module added
arianniaki Jul 12, 2017
347fa65
sanity check must be done before the reduce asn list
arianniaki Jul 13, 2017
3164ade
add arg for sanity check
grace71 Jul 15, 2017
eb26a35
move code under sanity check arg
grace71 Jul 16, 2017
845995c
add geo-sanity check module
grace71 Jul 16, 2017
1dcc045
combine sanity module and cli.py
grace71 Jul 16, 2017
739b509
get anchors before for loop
grace71 Jul 16, 2017
4c20719
some update
grace71 Jul 16, 2017
f8857c9
decouple ping and sanity check
grace71 Jul 17, 2017
0ffedcc
store sanity results as a file
grace71 Jul 19, 2017
f8d0182
add logging info & LICENSE
grace71 Jul 19, 2017
579b557
add timestamp for RIPE anchors monthly update
grace71 Jul 19, 2017
ba2dfa2
fix to deal with -1 in sanity check
grace71 Jul 19, 2017
35924fe
fix minor errors
grace71 Jul 21, 2017
84d5630
added downloader for map file
arianniaki Aug 2, 2017
93716ab
try block added for fetching map shape file
arianniaki Aug 2, 2017
9f76634
map shape file download (completed)
arianniaki Aug 2, 2017
fcb26e0
fixed a bug where servers.txt would be in the configs folder
arianniaki Aug 2, 2017
5fada31
fixed the previous bug completeley. purevpn had server in the name of…
arianniaki Aug 2, 2017
53ad69c
hostname resolution doesnt happen in the create configs anymore
arianniaki Aug 2, 2017
ff3c8d7
name resolution happens at sanity check instead of creating vpn confi…
arianniaki Aug 2, 2017
7ced45f
hostname resolution happens at sanity check instead of when creating …
arianniaki Aug 2, 2017
ab29b81
hash file of ovpn files added
arianniaki Aug 7, 2017
6941a61
update configs parameter added, reading configs pickle file added to …
arianniaki Aug 7, 2017
044e6d6
determine the update/add/delete vpn's in hma by comparing with the co…
arianniaki Aug 7, 2017
d519f41
new hash config file and server.txt file is written
arianniaki Aug 7, 2017
71bdd6c
add vpn config list implemented and all list of vp changes is returned
arianniaki Aug 7, 2017
db54733
remove/update/add vpn configs added in cli.py
arianniaki Aug 7, 2017
0898652
new configs created for new vps and in case the filenames are the sam…
arianniaki Aug 8, 2017
41595a4
fixed a bug where hostname was a tuple of filename and extension rath…
Aug 9, 2017
bed8b1d
removing new vpn configs folder when update is finished
Aug 9, 2017
0c98f71
update configs for ipvanish added
Aug 9, 2017
e6e2556
updated vpns directory shouldn't be deleted in the vpnprovider.py code
Aug 9, 2017
2a089dc
ipvanish update vpn config merged with cli.py
Aug 9, 2017
8866f0f
optimize the sanity checker
grace71 Aug 12, 2017
bd7128b
update vpn parameter added for purevpn
Aug 14, 2017
2cdb34a
Merge branch 'vpn_fixes' of https://github.com/arianniaki/centinel in…
Aug 14, 2017
3f43cad
adding return value to the update config function
arianniaki Aug 14, 2017
3bc4946
removing new vpns folder fetched for the update
arianniaki Aug 14, 2017
46cdd8b
changes to add custom_meta to configs file added
arianniaki Aug 14, 2017
cc93ca2
custom meta successfully added in confgis for each vp
arianniaki Aug 15, 2017
e503b6c
fix anchor parsing part to get city, country info
grace71 Sep 15, 2017
b4e9ed1
fix problem: by stopping openvpn properly
grace71 Sep 22, 2017
35164b5
speed up probing
grace71 Oct 24, 2017
f98dcfc
move getting gps part to probe.py
grace71 Oct 24, 2017
cafc62c
use RIPE API to get an anchors list
grace71 Oct 24, 2017
52437eb
change cli.py to run ripe api
grace71 Oct 24, 2017
653bc62
clean up probe part
grace71 Oct 24, 2017
2f7b845
clean up sanity check part
grace71 Oct 25, 2017
13c32c0
move sending pings to probe.py
grace71 Oct 25, 2017
ef52c1a
remove unnecessary config addition part
grace71 Oct 26, 2017
c92ad07
collect info for analysis
grace71 Oct 27, 2017
8c98199
erro msq
grace71 Oct 27, 2017
ff4348b
fix minor errors
grace71 Oct 27, 2017
ea8938f
Fix indents
grace71 Apr 19, 2018
31e03d0
Creat configs for other VP
grace71 Apr 29, 2018
2b7e5da
Fast enough not to store anchors lists
grace71 Apr 29, 2018
d7e0ad9
Subtract ping time from local to vp
grace71 Apr 29, 2018
e40f20b
Store online anchors list
grace71 Apr 29, 2018
d83574b
Move code to geosanity.py
grace71 Apr 30, 2018
b6202f5
Add column name for ping results
grace71 Apr 30, 2018
3229144
Finish geosanity.py
grace71 Apr 30, 2018
fa9f423
Change fname of landmark
grace71 May 2, 2018
a3c3d42
Store ping both to anchor and to proxy
grace71 May 5, 2018
3d3f0e1
Change vp_info format
grace71 May 9, 2018
cea8ada
Clean up codes for sanity check with speed
grace71 May 9, 2018
98ba2cb
Can't pickle staticmethod
grace71 May 9, 2018
11ec5ec
Fix errors
grace71 May 9, 2018
8768366
Handle geopy error and missed country code
grace71 May 10, 2018
16e8f89
Convert ms to second
grace71 May 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Expand Up @@ -21,3 +21,24 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Copyright (c) 2016 Zack Weinberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions centinel/config.py
Expand Up @@ -79,6 +79,8 @@ def __init__(self):
proxy['proxy'] = {proxy['proxy_type']: proxy['proxy_url']}
self.params['proxy'] = proxy

self.params['custom_meta'] = {}

def parse_config(self, config_file):
"""
Given a configuration file, read in and interpret the results
Expand Down
277 changes: 246 additions & 31 deletions centinel/vpn/cli.py 100755 → 100644

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions centinel/vpn/country_module.py
@@ -0,0 +1,102 @@
import geonamescache
from difflib import SequenceMatcher
from geopy.geocoders import Nominatim
from string import digits
import logging


def find_in_states(us_states, country):
"""
Given a country check if it is actually a US State
:param us_states: a list of us states
:param country: the country that we want to get its alpha code
:return:
"""
for state in us_states:
if(country in state):
return 'US'
return None

def manual_check(country):
"""
Some of the country names have spelling errors,
This function manually fixes those

:param country: the country that we want to get its alpha code
:return the alpha2 country codes:
"""
if(country == "Angula"):
return 'AO'
if(country == "Bosnia"):
return 'BA'
if(country == "UAE"):
return 'AE'
if(country == "LosAngeles"):
return 'US'
if(country == "Virgin Islands (British)"):
return 'VI'
if(country == "Korea"):
return 'KR'
if(country == "PitcairnIslands"):
return 'PN'
if(country == "RepublicofSingapore"):
return 'SG'
if(country == "USA"):
return 'US'
if(country == "Coted`Ivoire"):
return 'CI'
if(country == "Congo"):
return 'CD'
if(country == "Palestine"):
return 'PS'
if(country == "RepublicofDjibouti"):
return 'DJ'
return None

def country_to_a2(country):
"""
This function converts country names to their alpha2 codes
:param country: the country that we want to get its alpha code
:return the alpha2 country codes:
"""
gc = geonamescache.GeonamesCache()
countries = gc.get_countries()
us_states = gc.get_us_states_by_names()

# creating a dict between country name and alpha2 codes
countries_dict = {}
for item in countries:
countries_dict[countries[item]['name']] = item
countries_dict['United States of America'] = 'US'
countries_dict['Deutschland'] = 'DE'
countries_dict['UK'] = 'GB'

if ',' in country:
country = country.split(',')[0]
iso2 = countries_dict.get(country)
if (iso2 != None):
return iso2
else:
iso2 = find_in_states(us_states,country)
if(iso2 == None):
iso2 = manual_check(country)
if(iso2 == None):
for known_country in countries_dict:
if(SequenceMatcher(None, country, known_country).ratio()>0.70):
iso2 = countries_dict.get(known_country)
return iso2
else:
iso2 = None
if (iso2 == None):
try:
# for removing numbers from country/city names
country = country.translate(None, digits)
geolocator = Nominatim()
location = geolocator.geocode(country)
location = (location.address).split(',')
iso2 = (countries_dict.get(location[len(location)-1].strip()))
except:
# no mapping found
return None

return iso2
Empty file added centinel/vpn/expressvpn.py
Empty file.