mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-17 13:56:47 +00:00
libtorrent sync 1417
This commit is contained in:
parent
b0677d937b
commit
ed6b2ad3cf
@ -110,6 +110,8 @@ namespace libtorrent
|
||||
// the peer is not interested in our pieces
|
||||
void not_interested(peer_connection& c);
|
||||
|
||||
void ip_filter_updated();
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool has_connection(const peer_connection* p);
|
||||
|
||||
|
@ -175,6 +175,8 @@ namespace libtorrent
|
||||
boost::tuples::tuple<size_type, size_type> bytes_done() const;
|
||||
size_type quantized_bytes_done() const;
|
||||
|
||||
void ip_filter_updated() { m_policy->ip_filter_updated(); }
|
||||
|
||||
void pause();
|
||||
void resume();
|
||||
bool is_paused() const { return m_paused; }
|
||||
|
@ -304,6 +304,47 @@ namespace libtorrent
|
||||
, m_available_free_upload(0)
|
||||
, m_last_optimistic_disconnect(min_time())
|
||||
{ assert(t); }
|
||||
|
||||
// disconnects and removes all peers that are now filtered
|
||||
void policy::ip_filter_updated()
|
||||
{
|
||||
aux::session_impl& ses = m_torrent->session();
|
||||
piece_picker* p = 0;
|
||||
if (m_torrent->has_picker())
|
||||
p = &m_torrent->picker();
|
||||
for (std::list<peer>::iterator i = m_peers.begin()
|
||||
, end(m_peers.end()); i != end;)
|
||||
{
|
||||
if ((ses.m_ip_filter.access(i->ip.address()) & ip_filter::blocked) == 0)
|
||||
{
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i->connection)
|
||||
{
|
||||
i->connection->disconnect();
|
||||
if (ses.m_alerts.should_post(alert::info))
|
||||
{
|
||||
ses.m_alerts.post_alert(peer_blocked_alert(i->ip.address()
|
||||
, "disconnected blocked peer"));
|
||||
}
|
||||
assert(i->connection == 0
|
||||
|| i->connection->peer_info_struct() == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ses.m_alerts.should_post(alert::info))
|
||||
{
|
||||
ses.m_alerts.post_alert(peer_blocked_alert(i->ip.address()
|
||||
, "blocked peer removed from peer list"));
|
||||
}
|
||||
}
|
||||
if (p) p->clear_peer(&(*i));
|
||||
m_peers.erase(i++);
|
||||
}
|
||||
}
|
||||
|
||||
// finds the peer that has the worst download rate
|
||||
// and returns it. May return 0 if all peers are
|
||||
// choked.
|
||||
|
@ -613,29 +613,9 @@ namespace detail
|
||||
|
||||
// Close connections whose endpoint is filtered
|
||||
// by the new ip-filter
|
||||
for (session_impl::connection_map::iterator i
|
||||
= m_connections.begin(); i != m_connections.end();)
|
||||
{
|
||||
tcp::endpoint sender;
|
||||
try { sender = i->first->remote_endpoint(); }
|
||||
catch (std::exception&) { sender = i->second->remote(); }
|
||||
if (m_ip_filter.access(sender.address()) & ip_filter::blocked)
|
||||
{
|
||||
#if defined(TORRENT_VERBOSE_LOGGING)
|
||||
(*i->second->m_logger) << "*** CONNECTION FILTERED\n";
|
||||
#endif
|
||||
if (m_alerts.should_post(alert::info))
|
||||
{
|
||||
m_alerts.post_alert(peer_blocked_alert(sender.address()
|
||||
, "peer connection closed by IP filter"));
|
||||
}
|
||||
|
||||
session_impl::connection_map::iterator j = i;
|
||||
++i;
|
||||
j->second->disconnect();
|
||||
}
|
||||
else ++i;
|
||||
}
|
||||
for (torrent_map::iterator i = m_torrents.begin()
|
||||
, end(m_torrents.end()); i != end; ++i)
|
||||
i->second->ip_filter_updated();
|
||||
}
|
||||
|
||||
void session_impl::set_settings(session_settings const& s)
|
||||
|
Loading…
x
Reference in New Issue
Block a user