diff --git a/generate_api.sh b/generate_api.sh index b98150a..f68442e 100755 --- a/generate_api.sh +++ b/generate_api.sh @@ -33,4 +33,5 @@ process_header nng/include/nng/protocol/survey0/respond.h >> nng_api.h process_header nng/include/nng/supplemental/tls/tls.h | egrep -v "nng_tls_config_(pass|key)" >> nng_api.h process_header nng/include/nng/transport/tls/tls.h >> nng_api.h -grep '#define NNG_.*_VERSION' nng/include/nng/nng.h >> nng_api.h +grep '^#define NNG_FLAG' nng/include/nng/nng.h >> nng_api.h +grep '^#define NNG_.*_VERSION' nng/include/nng/nng.h >> nng_api.h diff --git a/nng_api.h b/nng_api.h index 876ae5b..e5cabb8 100644 --- a/nng_api.h +++ b/nng_api.h @@ -1,4 +1,4 @@ -// THIS FILE WAS AUTOMATICALLY GENERATED BY generate_api.sh +// THIS FILE WAS AUTOMATICALLY GENERATED BY ./generate_api.sh typedef struct nng_ctx_s { uint32_t id; } nng_ctx; @@ -276,7 +276,7 @@ extern void nng_sleep_aio(nng_duration, nng_aio *); extern int nng_msg_alloc(nng_msg **, size_t); extern void nng_msg_free(nng_msg *); extern int nng_msg_realloc(nng_msg *, size_t); -extern void *nng_msg_header(nng_msg *); +extern void * nng_msg_header(nng_msg *); extern size_t nng_msg_header_len(const nng_msg *); extern void * nng_msg_body(nng_msg *); extern size_t nng_msg_len(const nng_msg *); @@ -341,10 +341,6 @@ extern int nng_pipe_id(nng_pipe); extern nng_socket nng_pipe_socket(nng_pipe); extern nng_dialer nng_pipe_dialer(nng_pipe); extern nng_listener nng_pipe_listener(nng_pipe); -enum nng_flag_enum { - NNG_FLAG_ALLOC = 1, - NNG_FLAG_NONBLOCK = 2 -}; extern int nng_stats_get(nng_stat **); extern void nng_stats_free(nng_stat *); extern void nng_stats_dump(nng_stat *); @@ -545,6 +541,7 @@ int nng_pair0_open(nng_socket *); int nng_pair0_open_raw(nng_socket *); int nng_pair1_open(nng_socket *); int nng_pair1_open_raw(nng_socket *); +int nng_pair1_open_poly(nng_socket *); int nng_push0_open(nng_socket *); int nng_push0_open_raw(nng_socket *); int nng_pull0_open(nng_socket *); @@ -571,6 +568,12 @@ typedef enum nng_tls_auth_mode { NNG_TLS_AUTH_MODE_OPTIONAL = 1, NNG_TLS_AUTH_MODE_REQUIRED = 2, } nng_tls_auth_mode; +typedef enum nng_tls_version { + NNG_TLS_1_0 = 0x301, + NNG_TLS_1_1 = 0x302, + NNG_TLS_1_2 = 0x303, + NNG_TLS_1_3 = 0x304 +} nng_tls_version; int nng_tls_config_alloc(nng_tls_config **, nng_tls_mode); void nng_tls_config_hold(nng_tls_config *); void nng_tls_config_free(nng_tls_config *); @@ -583,7 +586,14 @@ int nng_tls_config_auth_mode(nng_tls_config *, nng_tls_auth_mode); int nng_tls_config_ca_file(nng_tls_config *, const char *); int nng_tls_config_cert_key_file( nng_tls_config *, const char *, const char *); +int nng_tls_config_version( + nng_tls_config *, nng_tls_version, nng_tls_version); +const char *nng_tls_engine_name(void); +const char *nng_tls_engine_description(void); +bool nng_tls_engine_fips_mode(void); int nng_tls_register(void); +#define NNG_FLAG_ALLOC 1u // Recv to allocate receive buffer +#define NNG_FLAG_NONBLOCK 2u // Non-blocking operations #define NNG_MAJOR_VERSION 1 -#define NNG_MINOR_VERSION 3 +#define NNG_MINOR_VERSION 4 #define NNG_PATCH_VERSION 0 diff --git a/pynng/nng.py b/pynng/nng.py index ba82c75..7593eab 100644 --- a/pynng/nng.py +++ b/pynng/nng.py @@ -692,7 +692,7 @@ class Pair0(Socket): class Pair1(Socket): - """A socket for bidrectional communication with potentially many partners. + """A socket for bidrectional communication with potentially many peers. The Python version of `nng_pair1 `_. @@ -701,10 +701,18 @@ class Pair1(Socket): keyword-only argument, ``polyamorous``, which must be set to ``True`` to connect with more than one peer. - .. Note:: + .. Warning:: If you want to connect to multiple peers you **must** pass - ``polyamorous=True`` when you create your socket. + ``polyamorous=True`` when you create your socket. ``polyamorous`` is a + read-only attribute of the socket and cannot be changed after creation. + + .. Warning:: + + Pair1 was an experimental feature in nng, and is currently deprecated. + It will likely be removed in the future; see `nng's docs + `_ for + details. To get the benefits of polyamory, you need to use the methods that work with :class:`Message` objects: :meth:`Socket.recv_msg` and @@ -724,22 +732,24 @@ class Pair1(Socket): """ - def __init__(self, *, polyamorous=None, **kwargs): + def __init__(self, *, polyamorous=False, **kwargs): # make sure we don't listen/dial before setting polyamorous, so we pop # them out of kwargs, then do the dial/listen below. # It's not beautiful, but it will work. dial_addr = kwargs.pop('dial', None) listen_addr = kwargs.pop('dial', None) super().__init__(**kwargs) - if polyamorous is not None: - self.polyamorous = polyamorous + if polyamorous: + self._opener = lib.nng_pair1_open_poly + else: + self._opener = lib.nng_pair1_open # now we can do the listen/dial if dial_addr is not None: self.dial(dial_addr, block=kwargs.get('block_on_dial')) if listen_addr is not None: self.listen(listen_addr) - _opener = lib.nng_pair1_open + _opener = lib.nng_pair1_open_poly polyamorous = BooleanOption('pair1:polyamorous') diff --git a/setup.py b/setup.py index b767afe..edbdba4 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ THIS_DIR = os.path.abspath(os.path.dirname(__file__)) NNG_REPO = 'https://github.com/nanomsg/nng' -NNG_REV = '60198afcb25766a5ca060c9d3c368c4d37ad40da' +NNG_REV = '4f5e11c391c4a8f1b2731aee5ad47bc0c925042a' MBEDTLS_REPO = 'https://github.com/ARMmbed/mbedtls.git' MBEDTLS_REV = '04a049bda1ceca48060b57bc4bcf5203ce591421'