summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/process.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-02-06 14:26:14 +0100
committerKali Kaneko (leap communications) <kali@leap.se>2017-02-23 00:40:39 +0100
commit1ba66d113ae0e3ce1651709c812426a3453d94d2 (patch)
tree49170c4e5871f5937cdd99d9e020d1c074c261f7 /src/leap/bitmask/vpn/process.py
parent7f07ffa13eaa51419af6f019bf9b36b298274485 (diff)
[feature] hard restarts upon ping-restart received
Diffstat (limited to 'src/leap/bitmask/vpn/process.py')
-rw-r--r--src/leap/bitmask/vpn/process.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/leap/bitmask/vpn/process.py b/src/leap/bitmask/vpn/process.py
index 82b4e7c3..c2941d01 100644
--- a/src/leap/bitmask/vpn/process.py
+++ b/src/leap/bitmask/vpn/process.py
@@ -57,8 +57,10 @@ class VPNProcess(protocol.ProcessProtocol, _management.VPNManagement):
programmatically.
"""
+ # TODO do we really need the eipconfig/providerconfig objects in here???
+
def __init__(self, eipconfig, providerconfig, socket_host, socket_port,
- openvpn_verb, remotes):
+ openvpn_verb, remotes, restartfun=None):
"""
:param eipconfig: eip configuration object
:type eipconfig: EIPConfig
@@ -93,9 +95,10 @@ class VPNProcess(protocol.ProcessProtocol, _management.VPNManagement):
# XXX use flags, maybe, instead of passing
# the parameter around.
self._openvpn_verb = openvpn_verb
+ self._restartfun = restartfun
self._status = _status.VPNStatus()
- self.is_restart = False
+ self.restarting = False
self._remotes = remotes
@@ -129,6 +132,8 @@ class VPNProcess(protocol.ProcessProtocol, _management.VPNManagement):
"""
# truncate the newline
line = data[:-1]
+ if 'SIGTERM[soft,ping-restart]' in line:
+ self.restarting = True
logger.info(line)
self._status.watch(line)
@@ -163,6 +168,9 @@ class VPNProcess(protocol.ProcessProtocol, _management.VPNManagement):
exit_code = reason.value.exitCode
if isinstance(exit_code, int):
logger.debug("processEnded, status %d" % (exit_code,))
+ if self.restarting:
+ logger.debug('Restarting VPN process')
+ reactor.callLater(2, self._restartfun)
# polling