diff --git a/ChangeLog b/ChangeLog index b67061d75..17a47f0ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -73,6 +73,7 @@ * added ability to give seeding torrents preference to active slots * added torrent_status::finished_time * automatically caps files and connections by default to rlimit + * added session::is_dht_running() function release 0.14.7 diff --git a/docs/manual.rst b/docs/manual.rst index d57e1f791..daf002faf 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -213,6 +213,7 @@ The ``session`` class has the following synopsis:: , int> const& node); void add_dht_router(std::pair const& node); + bool is_dht_running() const; void start_lsd(); void stop_lsd(); @@ -1064,8 +1065,8 @@ are ``hostname`` and ``port``. .. _i2p: http://www.i2p2.de -start_dht() stop_dht() set_dht_settings() dht_state() ------------------------------------------------------ +start_dht() stop_dht() set_dht_settings() dht_state() is_dht_running() +---------------------------------------------------------------------- :: @@ -1073,6 +1074,7 @@ start_dht() stop_dht() set_dht_settings() dht_state() void stop_dht(); void set_dht_settings(dht_settings const& settings); entry dht_state() const; + bool is_dht_running() const; These functions are not available in case ``TORRENT_DISABLE_DHT`` is defined. ``start_dht`` starts the dht node and makes the trackerless service @@ -1133,6 +1135,9 @@ that are ready to replace a failing node, it will be replaced immediately, this limit is only used to clear out nodes that don't have any node that can replace them. +``is_dht_running`` returns true if the DHT support has been started and false +otherwise. + add_dht_node() add_dht_router() ------------------------------- diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index b339bd0fd..aa2b87803 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -285,6 +285,7 @@ namespace libtorrent entry dht_state() const; void add_dht_node(std::pair const& node); void add_dht_router(std::pair const& node); + bool is_dht_running() const; #endif #ifndef TORRENT_DISABLE_ENCRYPTION diff --git a/src/session.cpp b/src/session.cpp index 9014e0f67..1cfe84ce8 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -618,6 +618,12 @@ namespace libtorrent m_impl->add_dht_router(node); } + bool session::is_dht_running() const + { + mutex::scoped_lock l(m_impl->m_mutex); + return m_impl->m_dht; + } + #endif #ifndef TORRENT_DISABLE_ENCRYPTION