diff options
author | Kali Kaneko <kali@leap.se> | 2017-08-22 23:15:38 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-08-30 16:18:00 -0400 |
commit | 2d7543e8c3828a8a0ab7b77b1c3a492c7ff28ed7 (patch) | |
tree | 581e98abdc1b412ec5ff2e1f7445d16cbaddcd74 /src/leap/bitmask/vpn/process.py | |
parent | a4e14e01b1f8259f72b27712c53bd50c0a8bf20f (diff) |
[refactor] move terminate_or_kill to linux launcher
Diffstat (limited to 'src/leap/bitmask/vpn/process.py')
-rw-r--r-- | src/leap/bitmask/vpn/process.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/leap/bitmask/vpn/process.py b/src/leap/bitmask/vpn/process.py index 0ba4b85a..48d3f1ad 100644 --- a/src/leap/bitmask/vpn/process.py +++ b/src/leap/bitmask/vpn/process.py @@ -22,11 +22,10 @@ A custom processProtocol launches the VPNProcess and connects to its management interface. """ +import os import shutil import sys -import psutil - from twisted.internet import protocol, reactor, defer from twisted.internet import error as internet_error from twisted.internet.endpoints import clientFromString, connectProtocol @@ -53,7 +52,8 @@ class _VPNProcess(protocol.ProcessProtocol): log = Logger() # HACK - reactor is expected to set this up when the process is spawned. - # should try to get it from within this class. + # should try to get it from the management protocol instead. + # XXX or, at least, we can check if they match. pid = None # TODO do we really need the vpnconfig/providerconfig objects in here??? @@ -82,6 +82,7 @@ class _VPNProcess(protocol.ProcessProtocol): reactor, b"unix:path=%s" % socket_host) else: raise ValueError('tcp endpoint not configured') + self._vpnconfig = vpnconfig self._providerconfig = providerconfig self._launcher = get_vpn_launcher() @@ -115,7 +116,6 @@ class _VPNProcess(protocol.ProcessProtocol): self._d.addErrback(self.log.error) def connectionMade(self): - self.aborted = False # TODO cut this wait time when retries are done reactor.callLater(0.5, self._connect_to_management) @@ -135,6 +135,9 @@ class _VPNProcess(protocol.ProcessProtocol): # TODO: need to exit properly! status, errmsg = 'off', None + # TODO ---- propagate this status upwards!! + # XXX do something with status + def processEnded(self, reason): """ Called when the child process exits and all file descriptors associated @@ -226,6 +229,11 @@ class _VPNProcess(protocol.ProcessProtocol): except internet_error.ProcessExitedAlready: self.log.debug('Process Exited Already') + def terminate_or_kill(self): + # XXX this returns a deferred + return self._launcher.terminate_or_kill( + self.terminate, self.kill, self) + if IS_LINUX: |