summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/tunnel.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2017-09-10 20:47:11 +0200
committerKali Kaneko <kali@leap.se>2017-09-10 22:11:32 +0200
commit0331bcc09c5fb602366c93ee35c95a2e320b78bd (patch)
treecfb6e178cca7a0314c3151a3da58c0664c1fbed9 /src/leap/bitmask/vpn/tunnel.py
parentafff83e87bb7322c9d01f71b8b12dbdc7f9d6ffe (diff)
[bug] mark vpn as failed if it had some problem starting
Diffstat (limited to 'src/leap/bitmask/vpn/tunnel.py')
-rw-r--r--src/leap/bitmask/vpn/tunnel.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/leap/bitmask/vpn/tunnel.py b/src/leap/bitmask/vpn/tunnel.py
index ce4707af..ae863203 100644
--- a/src/leap/bitmask/vpn/tunnel.py
+++ b/src/leap/bitmask/vpn/tunnel.py
@@ -99,23 +99,23 @@ class ConfiguredTunnel(object):
@defer.inlineCallbacks
def _start_vpn(self):
- self.log.debug('VPN: start')
- args = [self._vpnconfig, self._providerconfig,
- self._host, self._port]
- kwargs = {'openvpn_verb': 4, 'remotes': self._remotes,
- 'restartfun': self._restart_vpn}
- vpnproc = VPNProcess(*args, **kwargs)
- self._vpnproc = vpnproc
-
try:
+ self.log.debug('VPN: start')
+ args = [self._vpnconfig, self._providerconfig,
+ self._host, self._port]
+ kwargs = {'openvpn_verb': 4, 'remotes': self._remotes,
+ 'restartfun': self._restart_vpn}
+ vpnproc = VPNProcess(*args, **kwargs)
+ self._vpnproc = vpnproc
+
self.__start_pre_up(vpnproc)
cmd = self.__start_get_cmd(vpnproc)
running = yield self.__start_spawn_proc(vpnproc, cmd)
vpnproc.pid = running.pid
defer.returnValue(True)
except Exception:
- # TODO need to propagate the error message properly.
- defer.returnValue(False)
+ self._vpnproc.failed = True
+ raise
def __start_pre_up(self, proc):
try:
@@ -130,17 +130,17 @@ class ConfiguredTunnel(object):
except Exception as exc:
self.log.error(
'Error while getting vpn command... {0!r}'.format(exc))
- raise
+ raise exc
return cmd
def __start_spawn_proc(self, proc, cmd):
env = os.environ
try:
running_p = reactor.spawnProcess(proc, cmd[0], cmd, env)
- except Exception as e:
+ except Exception as exc:
self.log.error(
- 'Error while spawning vpn process... {0!r}'.format(e))
- return False
+ 'Error while spawning vpn process... {0!r}'.format(exc))
+ raise exc
return running_p
@defer.inlineCallbacks