applies ip filter to trackers as well
This commit is contained in:
@@ -55,6 +55,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "libtorrent/parse_url.hpp"
|
||||
#include "libtorrent/udp_tracker_connection.hpp"
|
||||
#include "libtorrent/io.hpp"
|
||||
#include "libtorrent/aux_/session_impl.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -80,7 +81,7 @@ namespace libtorrent
|
||||
, tracker_request const& req
|
||||
, address bind_infc
|
||||
, boost::weak_ptr<request_callback> c
|
||||
, session_settings const& stn
|
||||
, aux::session_impl const& ses
|
||||
, proxy_settings const& proxy)
|
||||
: tracker_connection(man, req, ios, bind_infc, c)
|
||||
, m_man(man)
|
||||
@@ -88,7 +89,7 @@ namespace libtorrent
|
||||
, m_socket(ios, boost::bind(&udp_tracker_connection::on_receive, self(), _1, _2, _3, _4), cc)
|
||||
, m_transaction_id(0)
|
||||
, m_connection_id(0)
|
||||
, m_settings(stn)
|
||||
, m_ses(ses)
|
||||
, m_attempts(0)
|
||||
, m_state(action_error)
|
||||
{
|
||||
@@ -111,14 +112,16 @@ namespace libtorrent
|
||||
return;
|
||||
}
|
||||
|
||||
session_settings const& settings = m_ses.settings();
|
||||
|
||||
udp::resolver::query q(hostname, boost::lexical_cast<std::string>(port));
|
||||
m_name_lookup.async_resolve(q
|
||||
, boost::bind(
|
||||
&udp_tracker_connection::name_lookup, self(), _1, _2));
|
||||
set_timeout(tracker_req().event == tracker_request::stopped
|
||||
? m_settings.stop_tracker_timeout
|
||||
: m_settings.tracker_completion_timeout
|
||||
, m_settings.tracker_receive_timeout);
|
||||
? settings.stop_tracker_timeout
|
||||
: settings.tracker_completion_timeout
|
||||
, settings.tracker_receive_timeout);
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||
boost::shared_ptr<request_callback> cb = requester();
|
||||
if (cb) cb->debug_log(("*** UDP_TRACKER [ initiating name lookup: " + hostname + " ]").c_str());
|
||||
@@ -165,6 +168,12 @@ namespace libtorrent
|
||||
{
|
||||
target_address = *target;
|
||||
}
|
||||
|
||||
if (m_ses.m_ip_filter.access(target_address.address()) & ip_filter::blocked)
|
||||
{
|
||||
fail(-1, "blocked by IP filter");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cb) cb->m_tracker_address = tcp::endpoint(target_address.address(), target_address.port());
|
||||
m_target = target_address;
|
||||
@@ -476,6 +485,7 @@ namespace libtorrent
|
||||
char* out = buf;
|
||||
|
||||
tracker_request const& req = tracker_req();
|
||||
session_settings const& settings = m_ses.settings();
|
||||
|
||||
detail::write_int64(m_connection_id, out); // connection_id
|
||||
detail::write_int32(action_announce, out); // action (announce)
|
||||
@@ -489,8 +499,8 @@ namespace libtorrent
|
||||
detail::write_int64(req.uploaded, out); // uploaded
|
||||
detail::write_int32(req.event, out); // event
|
||||
// ip address
|
||||
if (m_settings.announce_ip != address() && m_settings.announce_ip.is_v4())
|
||||
detail::write_uint32(m_settings.announce_ip.to_v4().to_ulong(), out);
|
||||
if (settings.announce_ip != address() && settings.announce_ip.is_v4())
|
||||
detail::write_uint32(settings.announce_ip.to_v4().to_ulong(), out);
|
||||
else
|
||||
detail::write_int32(0, out);
|
||||
detail::write_int32(req.key, out); // key
|
||||
|
Reference in New Issue
Block a user