diff --git a/ChangeLog b/ChangeLog index 944dc8222..80324a9f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -70,6 +70,8 @@ * almost completely changed the storage interface (for custom storage) * added support for hashing pieces in multiple threads + * expose missing dht_settings fields to python + * add function to query the DHT settings * fix bug in 'dont_count_slow_torrents' feature, which would start too many torrents diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 1d17f1f57..bbe7d81bb 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -664,6 +664,7 @@ void bind_session() ) .def("is_dht_running", allow_threads(<::session::is_dht_running)) .def("set_dht_settings", allow_threads(<::session::set_dht_settings)) + .def("get_dht_settings", allow_threads(<::session::get_dht_settings)) #endif .def("add_torrent", &add_torrent) .def("async_add_torrent", &async_add_torrent) diff --git a/bindings/python/src/session_settings.cpp b/bindings/python/src/session_settings.cpp index 058f5161e..a8dc7f526 100644 --- a/bindings/python/src/session_settings.cpp +++ b/bindings/python/src/session_settings.cpp @@ -284,6 +284,12 @@ void bind_session_settings() .def_readwrite("max_dht_items", &dht_settings::max_dht_items) .def_readwrite("restrict_routing_ips", &dht_settings::restrict_routing_ips) .def_readwrite("restrict_search_ips", &dht_settings::restrict_search_ips) + .def_readwrite("max_torrent_search_reply", &dht_settings::max_torrent_search_reply) + .def_readwrite("extended_routing_table", &dht_settings::extended_routing_table) + .def_readwrite("aggressive_lookups", &dht_settings::aggressive_lookups) + .def_readwrite("privacy_lookups", &dht_settings::privacy_lookups) + .def_readwrite("enforce_node_id", &dht_settings::enforce_node_id) + .def_readwrite("ignore_dark_internet", &dht_settings::ignore_dark_internet) ; #endif diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 317046ad5..0cdb7ca63 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -234,7 +234,7 @@ namespace libtorrent } start(flags, pack); } - + // The destructor of session will notify all trackers that our torrents // have been shut down. If some trackers are down, they will time out. // All this before the destructor of session returns. So, it's advised @@ -534,8 +534,11 @@ namespace libtorrent // ``is_dht_running()`` returns true if the DHT support has been started // and false // otherwise. + // + // ``get_dht_settings()`` returns the current settings void set_dht_settings(dht_settings const& settings); bool is_dht_running() const; + dht_settings get_dht_settings() const; // ``add_dht_node`` takes a host name and port pair. That endpoint will be // pinged, and if a valid DHT reply is received, the node will be added to diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 855218c08..d502e57e2 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -1498,7 +1498,7 @@ namespace libtorrent , block_timeout(5 * 60) , block_ratelimit(5) {} - + // the maximum number of peers to send in a reply to ``get_peers`` int max_peers_reply; @@ -1506,13 +1506,13 @@ namespace libtorrent // announcing and refreshing the routing table. This parameter is called // alpha in the kademlia paper int search_branching; - + #ifndef TORRENT_NO_DEPRECATE // the listen port for the dht. This is a UDP port. zero means use the // same as the tcp interface int service_port; #endif - + // the maximum number of failed tries to contact a node before it is // removed from the routing table. If there are known working nodes that // are ready to replace a failing node, it will be replaced immediately, diff --git a/src/session.cpp b/src/session.cpp index 81236a88a..f1ffe7eb1 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -816,6 +816,16 @@ namespace libtorrent #endif } + dht_settings session::get_dht_settings() const + { +#ifndef TORRENT_DISABLE_DHT + return TORRENT_SYNC_CALL_RET(dht_settings, get_dht_settings); +#else + return dht_settings(); +#endif + } + + #ifndef TORRENT_NO_DEPRECATE void session::start_dht(entry const& startup_state) { @@ -833,7 +843,7 @@ namespace libtorrent #endif } #endif // TORRENT_NO_DEPRECATE - + void session::add_dht_node(std::pair const& node) { #ifndef TORRENT_DISABLE_DHT