aboutsummaryrefslogtreecommitdiff
path: root/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'client.py')
-rw-r--r--client.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/client.py b/client.py
index 2c1b372..4b1c6a9 100644
--- a/client.py
+++ b/client.py
@@ -34,6 +34,7 @@ from helpers import (
timestamp_to_bytes,
bytes_to_timestamp,
write_yappi_stats,
+ auth_service,
)
###################################################
@@ -69,6 +70,7 @@ FPS = 30
# Maybe serial number from /proc/cpuinfo.
# In bytes.
CLIENT_ID = b"client_001"
+CERTIFICATE_DIRECTORY = 'certs'
#####################################################
# End defaults and constants #
@@ -373,7 +375,7 @@ class ClientTask(Thread):
Watch for new camera devices using inotify
"""
- def __init__(self, _id, context: zmq.Context=None) -> None:
+ def __init__(self, _id, context: zmq.Context) -> None:
"""
Parameters
----------
@@ -383,7 +385,7 @@ class ClientTask(Thread):
ZMQ context, by default None
"""
super().__init__(daemon=True)
- self.context = context or zmq.Context.instance()
+ self.context = context
self.socket = self.context.socket(zmq.DEALER)
self.identity = self.socket.identity = _id # <-- bytes
self.poll = zmq.Poller()
@@ -1049,7 +1051,14 @@ if __name__ == "__main__":
logger.info("Starting up ...")
- client = ClientTask(get_serial_number())
+ context = zmq.Context()
+ try:
+ auth_service(context, cert_dir=CERTIFICATE_DIRECTORY)
+ except Exception as exc:
+ logger.error("Error configuring authentication: %r", exc)
+ exit(1)
+
+ client = ClientTask(get_serial_number(), context)
client.start()
client.join()