2008-02-17 21:55:03 +01:00
|
|
|
// 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)
|
|
|
|
|
2016-04-08 04:45:23 +02:00
|
|
|
#include "boost_python.hpp"
|
2017-08-14 00:49:49 +02:00
|
|
|
#include <libtorrent/ip_filter.hpp>
|
2008-02-17 21:55:03 +01:00
|
|
|
#include "gil.hpp"
|
|
|
|
|
|
|
|
using namespace boost::python;
|
2017-04-12 20:05:53 +02:00
|
|
|
using namespace lt;
|
2008-02-17 21:55:03 +01:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void add_rule(ip_filter& filter, std::string start, std::string end, int flags)
|
|
|
|
{
|
2008-10-04 22:02:47 +02:00
|
|
|
return filter.add_rule(address::from_string(start), address::from_string(end), flags);
|
|
|
|
}
|
2008-10-30 21:56:54 +01:00
|
|
|
|
|
|
|
int access0(ip_filter& filter, std::string addr)
|
2008-10-04 22:02:47 +02:00
|
|
|
{
|
|
|
|
return filter.access(address::from_string(addr));
|
2008-02-17 21:55:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bind_ip_filter()
|
|
|
|
{
|
|
|
|
class_<ip_filter>("ip_filter")
|
2008-10-04 22:02:47 +02:00
|
|
|
.def("add_rule", add_rule)
|
2008-10-30 21:56:54 +01:00
|
|
|
.def("access", access0)
|
2008-10-04 22:02:47 +02:00
|
|
|
.def("export_filter", allow_threads(&ip_filter::export_filter))
|
2008-02-17 21:55:03 +01:00
|
|
|
;
|
|
|
|
}
|