summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/service.py
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-03-01 01:58:05 +0100
committerRuben Pollan <meskio@sindominio.net>2017-03-03 10:50:53 +0100
commitaf3866350e94c9238889a1c2485661466b1ec2dc (patch)
tree950511ec09ea238abb58de7ac28f2a5f19abec73 /src/leap/bitmask/vpn/service.py
parent4003aaaa124b1ffa77d07f7e2ae5d16e2dddacf1 (diff)
[bug] use username instead of provider in the vpn calls
Without active user we need to use the username instead of the provider in the VPN API. - Resolves: #8783
Diffstat (limited to 'src/leap/bitmask/vpn/service.py')
-rw-r--r--src/leap/bitmask/vpn/service.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py
index e56546ea..60de0f66 100644
--- a/src/leap/bitmask/vpn/service.py
+++ b/src/leap/bitmask/vpn/service.py
@@ -27,8 +27,6 @@ from twisted.internet import defer
from leap.bitmask.hooks import HookableService
from leap.bitmask.vpn.vpn import VPNManager
from leap.bitmask.vpn._checks import is_service_ready, get_vpn_cert_path
-from leap.bitmask.vpn._config import get_bitmask_helper_path
-from leap.bitmask.vpn._config import get_bitmask_polkit_policy_path
from leap.bitmask.vpn import privilege
from leap.common.config import get_path_prefix
from leap.common.files import check_and_fix_urw_only
@@ -88,22 +86,22 @@ class VPNService(HookableService):
status['domain'] = self._domain
return status
- def do_check(self):
+ def do_check(self, domain):
"""Check whether the VPN Service is properly configured,
and can be started"""
- # TODO either pass a provider, or set a given provider
- _ready = is_service_ready('demo.bitmask.net')
- if _ready:
- result = 'ok'
- else:
- result = 'no'
- return {'vpn_ready': result}
+ return {'vpn_ready': is_service_ready(domain)}
@defer.inlineCallbacks
- def do_get_cert(self, provider):
+ def do_get_cert(self, username):
+ try:
+ _, provider = username.split('@')
+ except ValueError:
+ raise ValueError(username + ' is not a valid username, it should'
+ ' contain an @')
+
# fetch vpn cert and store
bonafide = self.parent.getServiceNamed("bonafide")
- _, cert_str = yield bonafide.do_get_vpn_cert()
+ _, cert_str = yield bonafide.do_get_vpn_cert(username)
cert_path = get_vpn_cert_path(provider)
cert_dir = os.path.dirname(cert_path)