From 49fa0dd3d6c51d79096be1ac2ec3d897e607b399 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Tue, 31 Jan 2017 23:09:32 +0100 Subject: [refactor] minor renaming --- src/leap/bitmask/vpn/eip.py | 2 +- src/leap/bitmask/vpn/status.py | 42 +++++++++++++++++++++++++++++++++++++ src/leap/bitmask/vpn/statusqueue.py | 42 ------------------------------------- 3 files changed, 43 insertions(+), 43 deletions(-) create mode 100644 src/leap/bitmask/vpn/status.py delete mode 100644 src/leap/bitmask/vpn/statusqueue.py (limited to 'src/leap/bitmask/vpn') diff --git a/src/leap/bitmask/vpn/eip.py b/src/leap/bitmask/vpn/eip.py index cfd8b59..853fabd 100644 --- a/src/leap/bitmask/vpn/eip.py +++ b/src/leap/bitmask/vpn/eip.py @@ -20,7 +20,7 @@ from colorama import Fore from leap.bitmask.vpn import VPNManager from leap.bitmask.vpn.fw.firewall import FirewallManager -from leap.bitmask.vpn.statusqueue import StatusQueue +from leap.bitmask.vpn.status import StatusQueue from leap.bitmask.vpn.zmq_pub import ZMQPublisher diff --git a/src/leap/bitmask/vpn/status.py b/src/leap/bitmask/vpn/status.py new file mode 100644 index 0000000..ff7f311 --- /dev/null +++ b/src/leap/bitmask/vpn/status.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Queue used to store status changes on EIP/VPN/Firewall and to be checked for +any app using this vpn library. + +This should be considered a temporary code meant to replace the signaling +system that announces events inside of vpn code and is catched on the bitmask +client. +""" + +import Queue + + +class StatusQueue(object): + def __init__(self): + self._status = Queue.Queue() + + # this attributes serve to simulate events in the old signaler used + self.eip_network_unreachable = "network_unreachable" + self.eip_process_restart_tls = "process_restart_tls" + self.eip_process_restart_ping = "process_restart_ping" + self.eip_connected = "initialization_completed" + self.eip_status_changed = "status_changed" # has parameter + self.eip_state_changed = "state_changed" # has parameter + self.eip_process_finished = "process_finished" # has parameter + + def get_noblock(self): + s = None + try: + s = self._status.get(False) + except Queue.Empty: + pass + + return s + + def get(self): + return self._status.get(timeout=1) + + def signal(self, status, data=None): + self._status.put({'status': status, 'data': data}) diff --git a/src/leap/bitmask/vpn/statusqueue.py b/src/leap/bitmask/vpn/statusqueue.py deleted file mode 100644 index ff7f311..0000000 --- a/src/leap/bitmask/vpn/statusqueue.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -Queue used to store status changes on EIP/VPN/Firewall and to be checked for -any app using this vpn library. - -This should be considered a temporary code meant to replace the signaling -system that announces events inside of vpn code and is catched on the bitmask -client. -""" - -import Queue - - -class StatusQueue(object): - def __init__(self): - self._status = Queue.Queue() - - # this attributes serve to simulate events in the old signaler used - self.eip_network_unreachable = "network_unreachable" - self.eip_process_restart_tls = "process_restart_tls" - self.eip_process_restart_ping = "process_restart_ping" - self.eip_connected = "initialization_completed" - self.eip_status_changed = "status_changed" # has parameter - self.eip_state_changed = "state_changed" # has parameter - self.eip_process_finished = "process_finished" # has parameter - - def get_noblock(self): - s = None - try: - s = self._status.get(False) - except Queue.Empty: - pass - - return s - - def get(self): - return self._status.get(timeout=1) - - def signal(self, status, data=None): - self._status.put({'status': status, 'data': data}) -- cgit v1.2.3