diff --git a/AUTHORS b/AUTHORS index dd56b1e89..5a3d84e12 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,6 +12,7 @@ Daniel Wallin Cory Nelson Stas Khirman Ryan Norton +Andrew Resch Building and maintainance of the autotools scripts: Michael Wojciechowski diff --git a/bindings/python/src/docstrings.cpp b/bindings/python/src/docstrings.cpp index 15929515d..5afbc312a 100755 --- a/bindings/python/src/docstrings.cpp +++ b/bindings/python/src/docstrings.cpp @@ -177,6 +177,8 @@ char const* session_start_natpmp_doc = ""; char const* session_stop_natpmp_doc = ""; +char const* session_set_ip_filter_doc = + ""; // -- alert ----------------------------------------------------------------- char const* alert_doc = diff --git a/bindings/python/src/ip_filter.cpp b/bindings/python/src/ip_filter.cpp new file mode 100644 index 000000000..eed216141 --- /dev/null +++ b/bindings/python/src/ip_filter.cpp @@ -0,0 +1,28 @@ +// Copyright Andrew Resch 2008. Use, modification and distribution is +// subject to the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include "gil.hpp" + +using namespace boost::python; +using namespace libtorrent; + +namespace +{ + void add_rule(ip_filter& filter, std::string start, std::string end, int flags) + { + return filter.add_rule(address_v4::from_string(start), address_v4::from_string(end), flags); + } +} + +void bind_ip_filter() +{ + class_("ip_filter") + .def("add_rule", &add_rule) + .def("access", allow_threads(&ip_filter::access)) + .def_readonly("export_filter", allow_threads(&ip_filter::export_filter)) + ; +} + diff --git a/bindings/python/src/module.cpp b/bindings/python/src/module.cpp index 5c8d891d2..ea718388e 100755 --- a/bindings/python/src/module.cpp +++ b/bindings/python/src/module.cpp @@ -21,6 +21,7 @@ void bind_extensions(); void bind_peer_plugin(); void bind_torrent(); void bind_peer_info(); +void bind_ip_filter(); BOOST_PYTHON_MODULE(libtorrent) { @@ -44,5 +45,6 @@ BOOST_PYTHON_MODULE(libtorrent) bind_peer_plugin(); bind_torrent(); bind_peer_info(); + bind_ip_filter(); } diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 481348730..28fb6df98 100755 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "gil.hpp" @@ -56,6 +57,7 @@ extern char const* session_stop_lsd_doc; extern char const* session_stop_upnp_doc; extern char const* session_start_natpmp_doc; extern char const* session_stop_natpmp_doc; +extern char const* session_set_ip_filter_doc; namespace { @@ -248,6 +250,7 @@ void bind_session() .def("stop_lsd", allow_threads(&session::stop_lsd), session_stop_lsd_doc) .def("start_natpmp", allow_threads(&session::start_natpmp), session_start_natpmp_doc) .def("stop_natpmp", allow_threads(&session::stop_natpmp), session_stop_natpmp_doc) + .def("set_ip_filter", allow_threads(&session::set_ip_filter), session_set_ip_filter_doc) ; register_ptr_to_python >();