Skip to content
Snippets Groups Projects
Commit 29efd42d authored by Adrien Béraud's avatar Adrien Béraud
Browse files

python: add binding for SockAddr.resolve

parent ae2a1d83
Branches
No related tags found
No related merge requests found
...@@ -158,6 +158,15 @@ cdef class SockAddr(object): ...@@ -158,6 +158,15 @@ cdef class SockAddr(object):
return self.toString().decode() return self.toString().decode()
def __repr__(self): def __repr__(self):
return "<%s '%s'>" % (self.__class__.__name__, str(self)) return "<%s '%s'>" % (self.__class__.__name__, str(self))
@staticmethod
def resolve(str host, str service=None):
vals = []
result = cpp.SockAddr.resolve(host.encode(), service.encode() if service else b'')
for val in result:
a = SockAddr()
a._addr = val
vals.append(a)
return vals
cdef class Node(_WithID): cdef class Node(_WithID):
cdef shared_ptr[cpp.Node] _node cdef shared_ptr[cpp.Node] _node
......
...@@ -86,6 +86,8 @@ cdef extern from "opendht/sockaddr.h" namespace "dht": ...@@ -86,6 +86,8 @@ cdef extern from "opendht/sockaddr.h" namespace "dht":
bool isLoopback() const bool isLoopback() const
bool isPrivate() const bool isPrivate() const
bool isUnspecified() const bool isUnspecified() const
@staticmethod
vector[SockAddr] resolve(string host, string service) except +
ctypedef vector[uint8_t] Blob ctypedef vector[uint8_t] Blob
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment