diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index db35efffd..880dc2822 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -135,6 +135,34 @@ dict session_stats_values(session_stats_alert const& alert) return d; } +list dht_live_nodes_nodes(dht_live_nodes_alert const& alert) +{ + list result; + std::vector> const nodes = alert.nodes(); + for (std::pair const& node : nodes) + { + dict d; + d["nid"] = node.first; + d["endpoint"] = node.second; + result.append(d); + } + return result; +} + +list dht_sample_infohashes_nodes(dht_sample_infohashes_alert const& alert) +{ + list result; + std::vector> const nodes = alert.nodes(); + for (std::pair const& node : nodes) + { + dict d; + d["nid"] = node.first; + d["endpoint"] = node.second; + result.append(d); + } + return result; +} + #if TORRENT_ABI_VERSION == 1 entry const& get_resume_data_entry(save_resume_data_alert const& self) { @@ -1070,6 +1098,30 @@ void bind_alert() .add_property("ip", make_getter(&socks5_alert::ip, by_value())) ; + class_, noncopyable>( + "dht_live_nodes_alert", no_init) + .add_property("node_id", &dht_live_nodes_alert::node_id) + .add_property("num_nodes", &dht_live_nodes_alert::num_nodes) + .add_property("nodes", &dht_live_nodes_nodes) + ; + + std::vector (dht_sample_infohashes_alert::*samples)() const = &dht_sample_infohashes_alert::samples; + + class_, noncopyable>( + "dht_sample_infohashes_alert", no_init) + .add_property("endpoint", make_getter(&dht_sample_infohashes_alert::endpoint, by_value())) + .add_property("interval", make_getter(&dht_sample_infohashes_alert::interval, by_value())) + .add_property("num_infohashes", &dht_sample_infohashes_alert::num_infohashes) + .add_property("num_samples", &dht_sample_infohashes_alert::num_samples) + .add_property("samples", samples) + .add_property("num_nodes", &dht_sample_infohashes_alert::num_nodes) + .add_property("nodes", &dht_sample_infohashes_nodes) + ; + + class_, noncopyable>( + "dht_bootstrap_alert", no_init) + ; + } #ifdef _MSC_VER diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index c5174c271..31f0a5bc4 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -1017,6 +1017,8 @@ void bind_session() .def("dht_put_mutable_item", &dht_put_mutable_item) .def("dht_get_peers", allow_threads(<::session::dht_get_peers)) .def("dht_announce", allow_threads(<::session::dht_announce)) + .def("dht_live_nodes", allow_threads(<::session::dht_live_nodes)) + .def("dht_sample_infohashes", allow_threads(<::session::dht_sample_infohashes)) #endif // TORRENT_DISABLE_DHT .def("add_torrent", &add_torrent) .def("async_add_torrent", &async_add_torrent)