summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/service.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2017-08-11 13:17:37 -0400
committerKali Kaneko <kali@leap.se>2017-08-11 14:22:00 -0400
commit8487dcd0b9565657e1e6e89c7d8467d54a7c41ba (patch)
tree8dafa611cba74fa0427200c485baa408a2c27d6b /src/leap/bitmask/vpn/service.py
parent7a5b050ca704792a9b1c87d038db9851e8802473 (diff)
[feature] allow manual gateway selection for vpn
For now, the way to select a gateway is to add a section in bitmaskd.cfg: [vpn_prefs] locations = ["frankfurt", "seattle__wa"] countries = ["DE", "US"] Note that the location indication has priority over country code. This will be exposed by the UI in release 0.11 - Resolves: #8855
Diffstat (limited to 'src/leap/bitmask/vpn/service.py')
-rw-r--r--src/leap/bitmask/vpn/service.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py
index b0dcba8..d2f952e 100644
--- a/src/leap/bitmask/vpn/service.py
+++ b/src/leap/bitmask/vpn/service.py
@@ -19,7 +19,7 @@
"""
VPN service declaration.
"""
-
+import json
import os
from time import strftime
@@ -133,6 +133,7 @@ class VPNService(HookableService):
return {'result': 'vpn stopped'}
def do_status(self):
+ # TODO - add the current gateway and CC to the status
childrenStatus = {
'vpn': {'status': 'off', 'error': None},
'firewall': {'status': 'off', 'error': None},
@@ -220,10 +221,21 @@ class VPNService(HookableService):
bonafide = self.parent.getServiceNamed('bonafide')
config = yield bonafide.do_provider_read(provider, 'eip')
- sorted_gateways = GatewaySelector(
- config.gateways, config.locations).select_gateways()
+ 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 = []
- # TODO - add manual gateway selection ability.
+ sorted_gateways = GatewaySelector(
+ config.gateways, config.locations,
+ preferred={'cc': pref_cco, 'loc': pref_loc}
+ ).select_gateways()
extra_flags = config.openvpn_configuration