From c401c65dfba1da4792fe9edfc390221eb50cda3a Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 21 Jul 2009 01:52:37 +0000 Subject: [PATCH] Add get_ip_filter() to session --- ChangeLog | 1 + bindings/python/src/session.cpp | 1 + docs/manual.rst | 11 ++++++++++- include/libtorrent/aux_/session_impl.hpp | 2 ++ include/libtorrent/session.hpp | 2 ++ src/session.cpp | 5 +++++ src/session_impl.cpp | 6 ++++++ 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8aabcebc7..5dd184ac7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -82,6 +82,7 @@ release 0.14.5 disabled * fixed race condition in UPnP which could lead to crash * fixed inversed seed_time ratio logic + * added get_ip_filter() to session release 0.14.4 diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index bb54fcf0e..2d2d220ee 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -332,6 +332,7 @@ void bind_session() .def("start_natpmp", &start_natpmp) .def("stop_natpmp", allow_threads(&session::stop_natpmp)) .def("set_ip_filter", allow_threads(&session::set_ip_filter)) + .def("get_ip_filter", allow_threads(&session::get_ip_filter), return_value_policy()) .def("find_torrent", allow_threads(&session::find_torrent)) .def("get_torrents", &get_torrents) .def("pause", allow_threads(&session::pause)) diff --git a/docs/manual.rst b/docs/manual.rst index 0cf5c4a0d..6a1246d22 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -184,7 +184,8 @@ The ``session`` class has the following synopsis:: entry state() const; void set_ip_filter(ip_filter const& f); - + ip_filter const& get_ip_filter() const; + session_status status() const; cache_status get_cache_status() const; @@ -628,6 +629,14 @@ accepted and not, see ip_filter_. Each time a peer is blocked because of the IP filter, a peer_blocked_alert_ is generated. +get_ip_filter() +--------------- + + :: + ip_filter const& get_ip_filter() const; + +Returns the ip_filter currently in the session. See ip_filter_. + status() -------- diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index bd71a3c11..be16bcf40 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -204,6 +204,8 @@ namespace libtorrent void resume(); void set_ip_filter(ip_filter const& f); + ip_filter const& get_ip_filter() const; + void set_port_filter(port_filter const& f); bool listen_on( diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 18b7a080c..3bb95d662 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -308,6 +308,8 @@ namespace libtorrent entry state() const; void set_ip_filter(ip_filter const& f); + ip_filter const& get_ip_filter() const; + void set_port_filter(port_filter const& f); void set_peer_id(peer_id const& pid); void set_key(int key); diff --git a/src/session.cpp b/src/session.cpp index a7eb2550f..b1746e7b5 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -387,6 +387,11 @@ namespace libtorrent session_impl::mutex_t::scoped_lock l(m_impl->m_mutex); m_impl->set_ip_filter(f); } + + ip_filter const& session::get_ip_filter() const + { + m_impl->get_ip_filter(); + } void session::set_port_filter(port_filter const& f) { diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 9d50abc3d..ef3d39d11 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -620,6 +620,12 @@ namespace aux { i->second->ip_filter_updated(); } + ip_filter const& session_impl::get_ip_filter() const + { + mutex_t::scoped_lock l(m_mutex); + return m_ip_filter; + } + void session_impl::set_settings(session_settings const& s) { INVARIANT_CHECK;