From 701fe5ebc70fb49bb32e81e6d6605f27ad09925b Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Sat, 4 Feb 2017 17:01:25 +0100 Subject: [feature] parse status - simple status parsing - add separate firewall status - set status for abnormal termination --- src/leap/bitmask/vpn/_management.py | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'src/leap/bitmask/vpn/_management.py') diff --git a/src/leap/bitmask/vpn/_management.py b/src/leap/bitmask/vpn/_management.py index 920bd9d1..905372b1 100644 --- a/src/leap/bitmask/vpn/_management.py +++ b/src/leap/bitmask/vpn/_management.py @@ -45,16 +45,8 @@ class VPNManagement(object): # Timers, in secs CONNECTION_RETRY_TIME = 1 - def __init__(self, signaler=None): - """ - Initializes the VPNManager. - - :param signaler: Signaler object used to send notifications to the - backend - :type signaler: backend.Signaler - """ + def __init__(self): self._tn = None - self._signaler = signaler self.aborted = False def _seek_to_eof(self): @@ -227,8 +219,8 @@ class VPNManagement(object): def _parse_state_and_notify(self, output): """ - Parses the output of the state command and emits state_changed - signal when the state changes. + Parses the output of the state command, and trigger a state transition + when the state changes. :param output: list of lines that the state command printed as its output @@ -248,9 +240,9 @@ class VPNManagement(object): state = status_step if state != self._last_state: - if self._signaler is not None: - self._signaler.signal( - self._signaler.eip_state_changed, state) + # XXX this status object is the vpn status observer + if self._status: + self._status.set_status(state, None) self._last_state = state def _parse_status_and_notify(self, output): @@ -286,12 +278,12 @@ class VPNManagement(object): elif text == "TUN/TAP write bytes": tun_tap_write = value # upload - status = (tun_tap_read, tun_tap_write) - if status != self._last_status: - if self._signaler is not None: - self._signaler.signal( - self._signaler.eip_status_changed, status) - self._last_status = status + traffic_status = (tun_tap_read, tun_tap_write) + if traffic_status != self._last_status: + # XXX this status object is the vpn status observer + if self._status: + self._status.set_traffic_status(traffic_status) + self._last_status = traffic_status def get_state(self): """ -- cgit v1.2.3