From 0066be49b90396114442104c9247f6c9974c5c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Mon, 24 Dec 2018 16:55:25 -0500 Subject: [PATCH] python: add more bindings for SockAddr --- python/opendht.pyx | 6 ++++++ python/opendht_cpp.pxd | 3 +++ python/tools/pingpong.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/python/opendht.pyx b/python/opendht.pyx index 790b3e66..4ea8e490 100644 --- a/python/opendht.pyx +++ b/python/opendht.pyx @@ -139,6 +139,12 @@ cdef class SockAddr(object): return self._addr.setPort(port) def setFamily(SockAddr self, cpp.sa_family_t af): return self._addr.setFamily(af) + def isLoopback(SockAddr self): + return self._addr.isLoopback() + def isPrivate(SockAddr self): + return self._addr.isPrivate() + def isUnspecified(SockAddr self): + return self._addr.isUnspecified() def __str__(self): return self.toString().decode() def __repr__(self): diff --git a/python/opendht_cpp.pxd b/python/opendht_cpp.pxd index 3b889971..01cc4747 100644 --- a/python/opendht_cpp.pxd +++ b/python/opendht_cpp.pxd @@ -77,6 +77,9 @@ cdef extern from "opendht/sockaddr.h" namespace "dht": void setPort(in_port_t p) sa_family_t getFamily() const void setFamily(sa_family_t f) + bool isLoopback() const + bool isPrivate() const + bool isUnspecified() const ctypedef vector[uint8_t] Blob diff --git a/python/tools/pingpong.py b/python/tools/pingpong.py index b7db74e5..4634f59a 100755 --- a/python/tools/pingpong.py +++ b/python/tools/pingpong.py @@ -51,7 +51,7 @@ def ping(node, h): def pong(node, h): print(node.getNodeId().decode(), "got ping", h, i) - loop.call_soon_threadsafe(ping, node, h); + loop.call_soon_threadsafe(ping, node, h) return True ping_node.listen(loc_ping, lambda v: pong(pong_node, loc_pong)) -- GitLab