summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/service.py
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-08-30 19:54:37 +0200
committerRuben Pollan <meskio@sindominio.net>2017-08-31 12:56:43 +0200
commit663c87c221c42e081b5947e298bc9f0541e6913a (patch)
treed933acad5df919614e600aa1ae2e737ebcc6e472 /src/leap/bitmask/vpn/service.py
parentf19bfeb73fc19747bd02cbbd5c024de4dc86b5a8 (diff)
[feat] list vpn gateways in the order that they are going to be used
Diffstat (limited to 'src/leap/bitmask/vpn/service.py')
-rw-r--r--src/leap/bitmask/vpn/service.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py
index f4af3036..6588e1d5 100644
--- a/src/leap/bitmask/vpn/service.py
+++ b/src/leap/bitmask/vpn/service.py
@@ -194,7 +194,8 @@ class VPNService(HookableService):
config = yield bonafide.do_provider_read(provider, 'eip')
except ValueError:
continue
- provider_dict[provider] = config.locations
+ gateways = self._gateways(config)
+ provider_dict[provider] = gateways.get_sorted_gateways()
defer.returnValue(provider_dict)
@defer.inlineCallbacks
@@ -207,21 +208,7 @@ class VPNService(HookableService):
bonafide = self.parent.getServiceNamed('bonafide')
config = yield bonafide.do_provider_read(provider, 'eip')
- try:
- _cco = self.parent.get_config('vpn_prefs', 'countries', "")
- pref_cco = json.loads(_cco)
- except ValueError:
- pref_cco = []
- try:
- _loc = self.parent.get_config('vpn_prefs', 'locations', "")
- pref_loc = json.loads(_loc)
- except ValueError:
- pref_loc = []
-
- sorted_gateways = GatewaySelector(
- config.gateways, config.locations,
- preferred={'cc': pref_cco, 'loc': pref_loc}
- ).select_gateways()
+ sorted_gateways = self._gateways(config).select_gateways()
extra_flags = config.openvpn_configuration
@@ -244,6 +231,23 @@ class VPNService(HookableService):
provider, remotes, cert_path, key_path, ca_path, extra_flags)
self._firewall = FirewallManager(remotes)
+ def _gateways(self, config):
+ try:
+ _cco = self.parent.get_config('vpn_prefs', 'countries', "")
+ pref_cco = json.loads(_cco)
+ except ValueError:
+ pref_cco = []
+ try:
+ _loc = self.parent.get_config('vpn_prefs', 'locations', "")
+ pref_loc = json.loads(_loc)
+ except ValueError:
+ pref_loc = []
+
+ return GatewaySelector(
+ config.gateways, config.locations,
+ preferred={'cc': pref_cco, 'loc': pref_loc}
+ )
+
def _cert_expires(self, provider):
path = os.path.join(
self._basepath, "leap", "providers", provider,