summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/statusqueue.py
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-01-31 13:31:13 +0100
committerKali Kaneko (leap communications) <kali@leap.se>2017-02-23 00:37:25 +0100
commitca0e1c4518749e27bccad817d22ab87afbf8acf7 (patch)
tree636c1188683c1ea91d70b3aecd2810aafa7cf724 /src/leap/bitmask/vpn/statusqueue.py
parentff5ec25029db7669163854886be254fccde90e80 (diff)
[feature] initial port of legacy vpn code
non functional at the moment, but started doing some cleanup
Diffstat (limited to 'src/leap/bitmask/vpn/statusqueue.py')
-rw-r--r--src/leap/bitmask/vpn/statusqueue.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/leap/bitmask/vpn/statusqueue.py b/src/leap/bitmask/vpn/statusqueue.py
new file mode 100644
index 00000000..ff7f3111
--- /dev/null
+++ b/src/leap/bitmask/vpn/statusqueue.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})