mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
use libuv for networking and event scheduling
This commit is contained in:
1 parent
5a75b54e04
commit
4a97265b22
19 files changed
+799
-495
No files matched your search
+12
-8
@@ -300,6 +300,8 @@ cdef class NodeSet(object):
|
||||
return s
|
||||
def __iter__(self):
|
||||
return NodeSetIter(self)
|
||||
def __len__(self):
|
||||
return self.size()
|
||||
|
||||
cdef class PrivateKey(_WithID):
|
||||
cdef shared_ptr[cpp.PrivateKey] _key
|
||||
@@ -442,6 +444,10 @@ cdef class DhtConfig(object):
|
||||
self._config.dht_config.node_config.node_id = id._infohash
|
||||
def setNetwork(self, unsigned netid):
|
||||
self._config.dht_config.node_config.network = netid
|
||||
def setPort(self, cpp.in_port_t port):
|
||||
self._config.dht_config.node_config.network_config.bind_port = port
|
||||
def setBindAddr(self, string addr):
|
||||
self._config.dht_config.node_config.network_config.bind_addr = addr
|
||||
def setMaintainStorage(self, bool maintain_storage):
|
||||
self._config.dht_config.node_config.maintain_storage = maintain_storage
|
||||
|
||||
@@ -484,12 +490,10 @@ cdef class DhtRunner(_WithID):
|
||||
def run(self, Identity id=None, is_bootstrap=False, cpp.in_port_t port=0, str ipv4="", str ipv6="", DhtConfig config=DhtConfig()):
|
||||
if id:
|
||||
config.setIdentity(id)
|
||||
if ipv4 or ipv6:
|
||||
bind4 = ipv4.encode() if ipv4 else b''
|
||||
bind6 = ipv6.encode() if ipv6 else b''
|
||||
self.thisptr.get().run(bind4, bind6, str(port).encode(), config._config)
|
||||
else:
|
||||
self.thisptr.get().run(port, config._config)
|
||||
config.setPort(port)
|
||||
if ipv6:
|
||||
config.setBindAddr(ipv6)
|
||||
self.thisptr.get().run(config._config)
|
||||
def join(self):
|
||||
self.thisptr.get().join()
|
||||
def shutdown(self, shutdown_cb=None):
|
||||
@@ -504,9 +508,9 @@ cdef class DhtRunner(_WithID):
|
||||
cpp.enableFileLogging(self.thisptr.get()[0], path.encode())
|
||||
def isRunning(self):
|
||||
return self.thisptr.get().isRunning()
|
||||
def getBound(self, cpp.sa_family_t af = 0):
|
||||
def getBound(self):
|
||||
s = SockAddr()
|
||||
s._addr = self.thisptr.get().getBound(af)
|
||||
s._addr = self.thisptr.get().getBound()
|
||||
return s
|
||||
def getStorageLog(self):
|
||||
return self.thisptr.get().getStorageLog().decode()
|
||||
|
||||
@@ -73,7 +73,7 @@ cdef extern from "opendht/sockaddr.h" namespace "dht":
|
||||
SockAddr() except +
|
||||
string toString() const
|
||||
in_port_t getPort() const
|
||||
void setPort(in_port_t p)
|
||||
void setPort(in_port_t p) const
|
||||
sa_family_t getFamily() const
|
||||
void setFamily(sa_family_t f)
|
||||
|
||||
@@ -198,11 +198,15 @@ cdef extern from "opendht/callbacks.h" namespace "dht":
|
||||
cdef DoneCallback bindDoneCb(DoneCallbackRaw cb, void *user_data)
|
||||
cdef DoneCallbackSimple bindDoneCbSimple(DoneCallbackSimpleRaw cb, void *user_data)
|
||||
|
||||
cppclass NetworkConfig:
|
||||
string bind_addr
|
||||
in_port_t bind_port
|
||||
cppclass Config:
|
||||
InfoHash node_id
|
||||
uint32_t network
|
||||
bool is_bootstrap
|
||||
bool maintain_storage
|
||||
NetworkConfig network_config
|
||||
cppclass SecureDhtConfig:
|
||||
Config node_config
|
||||
Identity id
|
||||
@@ -219,12 +223,11 @@ cdef extern from "opendht/dhtrunner.h" namespace "dht":
|
||||
InfoHash getNodeId() const
|
||||
void bootstrap(const_char*, const_char*)
|
||||
void bootstrap(const SockAddr&, DoneCallbackSimple done_cb)
|
||||
void run(in_port_t, Config config)
|
||||
void run(const_char*, const_char*, const_char*, Config config)
|
||||
void run(Config config)
|
||||
void join()
|
||||
void shutdown(ShutdownCallback)
|
||||
bool isRunning()
|
||||
SockAddr getBound(sa_family_t af) const
|
||||
SockAddr getBound() const
|
||||
string getStorageLog() const
|
||||
string getRoutingTablesLog(sa_family_t af) const
|
||||
string getSearchesLog(sa_family_t af) const
|
||||
|
||||
+2
-2
@@ -50,8 +50,8 @@ setup(name="opendht",
|
||||
["@CURRENT_SOURCE_DIR@/opendht.pyx"],
|
||||
include_dirs = ['@PROJECT_SOURCE_DIR@/include'],
|
||||
language="c++",
|
||||
extra_compile_args=["-std=c++11"],
|
||||
extra_link_args=["-std=c++11"],
|
||||
extra_compile_args=["-std=c++14"],
|
||||
extra_link_args=["-std=c++14"],
|
||||
libraries=["opendht"],
|
||||
library_dirs = ['@CURRENT_BINARY_DIR@', '@PROJECT_BINARY_DIR@']
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user