From 7909479505cbf49332cd93cc915d2108749aa3f6 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 13 Oct 2012 02:08:34 +0000 Subject: [PATCH] merged python fix from RC_0_16 --- ChangeLog | 1 + bindings/python/src/session.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 108f803ea..fede7d334 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * introduce a way to add built-in plugins from python * consistently disconnect the same peer when two peers simultaneously connect * fix local endpoint queries for uTP connections * small optimization to local peer discovery to ignore our own broadcasts diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 8b08dd1f1..ff5642ca1 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -12,6 +12,13 @@ #include #include #include + +#include +#include +#include +#include +#include + #include "gil.hpp" using namespace boost::python; @@ -43,8 +50,24 @@ namespace } #endif + void add_extension(session& s, object const& e) + { + if (!extract(e).check()) return; + + std::string name = extract(e); + if (name == "ut_metadata") + s.add_extension(create_ut_metadata_plugin); + else if (name == "ut_pex") + s.add_extension(create_ut_pex_plugin); + else if (name == "smart_ban") + s.add_extension(create_smart_ban_plugin); + else if (name == "lt_trackers") + s.add_extension(create_lt_trackers_plugin); + else if (name == "metadata_transfer") + s.add_extension(create_metadata_plugin); + } + #ifndef TORRENT_NO_DEPRECATE - void add_extension(session& s, object const& e) {} boost::shared_ptr dummy_plugin_wrapper(torrent* t) { return boost::shared_ptr(); @@ -590,8 +613,8 @@ void bind_session() .def("set_alert_mask", allow_threads(&session::set_alert_mask)) .def("pop_alert", allow_threads(&session::pop_alert)) .def("wait_for_alert", &wait_for_alert, return_internal_reference<>()) -#ifndef TORRENT_NO_DEPRECATE .def("add_extension", &add_extension) +#ifndef TORRENT_NO_DEPRECATE .def("set_peer_proxy", allow_threads(&session::set_peer_proxy)) .def("set_tracker_proxy", allow_threads(&session::set_tracker_proxy)) .def("set_web_seed_proxy", allow_threads(&session::set_web_seed_proxy))