def _zmq_has_curve(): """ Return whether the current ZMQ has support for auth and CurveZMQ security. :rtype: bool Version notes: `zmq.curve_keypair()` is new in version 14.0, new in version libzmq-4.0. Requires libzmq (>= 4.0) to have been linked with libsodium. `zmq.auth` module is new in version 14.1 `zmq.has()` is new in version 14.1, new in version libzmq-4.1. """ zmq_version = zmq.zmq_version_info() pyzmq_version = zmq.pyzmq_version_info() if pyzmq_version >= (14, 1, 0) and zmq_version >= (4, 1): return zmq.has('curve') if pyzmq_version < (14, 1, 0): return False if zmq_version < (4, 0): # security is new in libzmq 4.0 return False try: zmq.curve_keypair() except zmq.error.ZMQError: # security requires libzmq to be linked against libsodium return False return True
def log_sysinfo(app: Flask, config: Config): app.logger.info("ZMQ:") app.logger.info(" zmq version: %s", zmq.zmq_version()) app.logger.info(" pyzmq version: %s", zmq.pyzmq_version()) app.logger.info(" zmq includes: %s", zmq.get_includes()) app.logger.info(" zmq library dirs: %s", zmq.get_library_dirs()) app.logger.info(" has: %s", [c for c in ZMQ_CAPABILITIES if zmq.has(c)]) app.logger.info("socket:") app.logger.info(" fqdn: %s", socket.getfqdn()) app.logger.info(" has_ipv6: %s", socket.has_ipv6) app.logger.info(" hostname: %s", socket.gethostname()) app.logger.info(" interfaces: %s", [i[1] for i in socket.if_nameindex()]) app.logger.info("os:") app.logger.info(" ctermid: %s", os.ctermid()) app.logger.info(" cwd: %s", os.getcwd()) app.logger.info(" groups: %s", os.getgroups()) app.logger.info(" pgid: %d", os.getpgid(0)) app.logger.info(" pgrp: %d", os.getpgrp()) app.logger.info(" pid: %d", os.getpid()) app.logger.info(" ppid: %d", os.getppid()) app.logger.info(" priority_process: %d", os.getpriority(os.PRIO_PROCESS, 0)) app.logger.info(" priority_pgrp: %d", os.getpriority(os.PRIO_PGRP, 0)) app.logger.info(" priority_user: %d", os.getpriority(os.PRIO_USER, 0)) app.logger.info(" resuid: ruid=%d, euid=%d, suid=%d", *os.getresuid()) app.logger.info(" resgid: rgid=%d, egid=%d, sgid=%d", *os.getresgid()) app.logger.info(" sid: %d", os.getsid(0)) app.logger.info(" supports_bytes_environ: %s", os.supports_bytes_environ) app.logger.info(" uname: %s", os.uname()) app.logger.info(" cpu_count: %d", os.cpu_count()) app.logger.info("platform:") app.logger.info(" %s", platform.platform()) app.logger.info(" python_build: %s", platform.python_build()) app.logger.info(" python_compiler: %s", platform.python_compiler()) app.logger.info(" python_branch: %s", platform.python_branch()) app.logger.info(" python_implementation: %s", platform.python_implementation()) app.logger.info(" python_revision: %s", platform.python_revision()) app.logger.info(" python_version: %s", platform.python_version()) app.logger.info("getpass:"******" user: %s", getpass.getuser())
def test_has_curve(): """bundled libzmq has curve support""" assert zmq.has('curve')
def test_has(): assert not zmq.has('something weird') has_ipc = zmq.has('ipc') not_windows = not sys.platform.startswith('win') assert has_ipc == not_windows
import zmq zmq.has("feature") public, secret = zmq.curve_keypair()