summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/bitmask/cli/command.py5
-rw-r--r--src/leap/bitmask/vpn/launcher.py4
-rw-r--r--src/leap/bitmask/vpn/service.py14
-rw-r--r--src/leap/bitmask/vpn/vpn.py8
4 files changed, 25 insertions, 6 deletions
diff --git a/src/leap/bitmask/cli/command.py b/src/leap/bitmask/cli/command.py
index 77d2bdfc..cc3514b0 100644
--- a/src/leap/bitmask/cli/command.py
+++ b/src/leap/bitmask/cli/command.py
@@ -148,9 +148,12 @@ class Command(object):
if self.print_json:
print(json.dumps(obj, indent=2))
elif not obj['error']:
- if not obj['result']:
+ if 'result' not in obj:
print (Fore.RED + 'ERROR: malformed response, expected'
' obj["result"]' + Fore.RESET)
+ elif obj['result'] is None:
+ print (Fore.RED + 'ERROR: empty response. Check logs.' +
+ Fore.RESET)
else:
return printer(obj['result'])
else:
diff --git a/src/leap/bitmask/vpn/launcher.py b/src/leap/bitmask/vpn/launcher.py
index 28c8a31f..f412acef 100644
--- a/src/leap/bitmask/vpn/launcher.py
+++ b/src/leap/bitmask/vpn/launcher.py
@@ -201,7 +201,9 @@ class VPNLauncher(object):
if not os.path.isfile(openvpn_path):
log.warn('Could not find openvpn bin in path %s' % (
openvpn_path))
- raise OpenVPNNotFoundException()
+ err = OpenVPNNotFoundException()
+ err.expected = True
+ raise err
args = []
diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py
index 874c30d3..5ab1e97e 100644
--- a/src/leap/bitmask/vpn/service.py
+++ b/src/leap/bitmask/vpn/service.py
@@ -78,16 +78,24 @@ class VPNService(HookableService):
exc.expected = True
raise exc
yield self._setup(domain)
+
try:
- self._vpn.start()
+ started = self._vpn.start()
+
+ # XXX capture it inside start method
+ # here I'd like to get (status, message)
except NoPolkitAuthAgentAvailable as e:
e.expected = True
raise e
+ # --------------------------------------
- self._started = True
+ self._started = started
self._domain = domain
self._write_last(domain)
- defer.returnValue({'result': 'started'})
+ if started:
+ defer.returnValue({'result': 'started'})
+ else:
+ raise Exception('Could not start VPN, check logs')
def stop_vpn(self):
# TODO -----------------------------
diff --git a/src/leap/bitmask/vpn/vpn.py b/src/leap/bitmask/vpn/vpn.py
index 677c9b91..23f0a582 100644
--- a/src/leap/bitmask/vpn/vpn.py
+++ b/src/leap/bitmask/vpn/vpn.py
@@ -44,7 +44,12 @@ class VPNManager(object):
return False
print(Fore.GREEN + "Firewall: started" + Fore.RESET)
- vpn_ok = self._vpn.start()
+ try:
+ vpn_ok = self._vpn.start()
+ except Exception:
+ self.starting = False
+ return False
+
if not vpn_ok:
print (Fore.RED + "VPN: Error starting." + Fore.RESET)
self._firewall.stop()
@@ -52,6 +57,7 @@ class VPNManager(object):
self.starting = False
return False
print(Fore.GREEN + "VPN: started" + Fore.RESET)
+ return True
def stop(self):
self.starting = False