summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/backend/signaler.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-02-23 14:45:48 -0400
committerKali Kaneko <kali@leap.se>2015-02-23 14:45:48 -0400
commit1f4e0c32f49337e216eaaac83a8eeca9674370a4 (patch)
treec20f0ff4a6e177667f3a2233f2ef6eb7e2ee9233 /src/leap/bitmask/backend/signaler.py
parent4bad7062364c72215da9fd2256451c7a3d0a356f (diff)
parent04be045242b0fd0c669610f54db7a9fdeb3b77f3 (diff)
Merge remote-tracking branch 'leapcode/pr/826' into release/0.8.x
Diffstat (limited to 'src/leap/bitmask/backend/signaler.py')
-rw-r--r--src/leap/bitmask/backend/signaler.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/leap/bitmask/backend/signaler.py b/src/leap/bitmask/backend/signaler.py
index 43cba994..aec2f606 100644
--- a/src/leap/bitmask/backend/signaler.py
+++ b/src/leap/bitmask/backend/signaler.py
@@ -26,6 +26,7 @@ import zmq
from leap.bitmask.backend.api import SIGNALS
from leap.bitmask.backend.utils import get_frontend_certificates
+from leap.bitmask.config import flags
import logging
logger = logging.getLogger(__name__)
@@ -36,8 +37,11 @@ class Signaler(object):
Signaler client.
Receives signals from the backend and sends to the signaling server.
"""
- PORT = "5667"
- SERVER = "tcp://localhost:%s" % PORT
+ if flags.ZMQ_HAS_CURVE:
+ PORT = "5667"
+ SERVER = "tcp://localhost:%s" % PORT
+ else:
+ SERVER = "ipc:///tmp/bitmask.socket.1"
POLL_TIMEOUT = 2000 # ms
POLL_TRIES = 500
@@ -49,15 +53,16 @@ class Signaler(object):
logger.debug("Connecting to signaling server...")
socket = context.socket(zmq.REQ)
- # public, secret = zmq.curve_keypair()
- client_keys = zmq.curve_keypair()
- socket.curve_publickey = client_keys[0]
- socket.curve_secretkey = client_keys[1]
+ if flags.ZMQ_HAS_CURVE:
+ # public, secret = zmq.curve_keypair()
+ client_keys = zmq.curve_keypair()
+ socket.curve_publickey = client_keys[0]
+ socket.curve_secretkey = client_keys[1]
- # The client must know the server's public key to make a CURVE
- # connection.
- public, _ = get_frontend_certificates()
- socket.curve_serverkey = public
+ # The client must know the server's public key to make a CURVE
+ # connection.
+ public, _ = get_frontend_certificates()
+ socket.curve_serverkey = public
socket.setsockopt(zmq.RCVTIMEO, 1000)
socket.setsockopt(zmq.LINGER, 0) # Terminate early