applied python binding patch to expose ip_filter. #275
This commit is contained in:
@@ -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 =
|
||||
|
28
bindings/python/src/ip_filter.cpp
Normal file
28
bindings/python/src/ip_filter.cpp
Normal file
@@ -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 <libtorrent/ip_filter.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#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>("ip_filter")
|
||||
.def("add_rule", &add_rule)
|
||||
.def("access", allow_threads(&ip_filter::access))
|
||||
.def_readonly("export_filter", allow_threads(&ip_filter::export_filter))
|
||||
;
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include <libtorrent/session.hpp>
|
||||
#include <libtorrent/torrent.hpp>
|
||||
#include <libtorrent/storage.hpp>
|
||||
#include <libtorrent/ip_filter.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#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<std::auto_ptr<alert> >();
|
||||
|
Reference in New Issue
Block a user