made peer_blocked_alert derive from torrent_alert

This commit is contained in:
Arvid Norberg 2009-09-07 01:47:30 +00:00
parent 3ea1b0d304
commit 3e9725b5d7
5 changed files with 18 additions and 13 deletions

View File

@ -5423,7 +5423,7 @@ address that was blocked.
::
struct peer_blocked_alert: alert
struct peer_blocked_alert: torrent_alert
{
// ...
address ip;

View File

@ -1313,10 +1313,11 @@ namespace libtorrent
}
};
struct TORRENT_EXPORT peer_blocked_alert: alert
struct TORRENT_EXPORT peer_blocked_alert: torrent_alert
{
peer_blocked_alert(address const& ip_)
: ip(ip_)
peer_blocked_alert(torrent_handle const& h, address const& ip_)
: torrent_alert(h)
, ip(ip_)
{}
address ip;
@ -1329,7 +1330,7 @@ namespace libtorrent
virtual std::string message() const
{
error_code ec;
return "blocked peer: " + ip.to_string(ec);
return torrent_alert::message() + ": blocked peer: " + ip.to_string(ec);
}
};

View File

@ -306,14 +306,14 @@ namespace libtorrent
{
(*i)->connection->disconnect(error_code(errors::banned_by_ip_filter, libtorrent_category));
if (ses.m_alerts.should_post<peer_blocked_alert>())
ses.m_alerts.post_alert(peer_blocked_alert((*i)->address()));
ses.m_alerts.post_alert(peer_blocked_alert(m_torrent->get_handle(), (*i)->address()));
TORRENT_ASSERT((*i)->connection == 0
|| (*i)->connection->peer_info_struct() == 0);
}
else
{
if (ses.m_alerts.should_post<peer_blocked_alert>())
ses.m_alerts.post_alert(peer_blocked_alert((*i)->address()));
ses.m_alerts.post_alert(peer_blocked_alert(m_torrent->get_handle(), (*i)->address()));
}
int current = i - m_peers.begin();
erase_peer(i);
@ -1048,13 +1048,17 @@ namespace libtorrent
// if this is an i2p torrent, and we don't allow mixed mode
// no regular peers should ever be added!
if (!ses.m_settings.allow_i2p_mixed && m_torrent->torrent_file().is_i2p())
{
if (ses.m_alerts.should_post<peer_blocked_alert>())
ses.m_alerts.post_alert(peer_blocked_alert(m_torrent->get_handle(), remote.address()));
return 0;
}
port_filter const& pf = ses.m_port_filter;
if (pf.access(remote.port()) & port_filter::blocked)
{
if (ses.m_alerts.should_post<peer_blocked_alert>())
ses.m_alerts.post_alert(peer_blocked_alert(remote.address()));
ses.m_alerts.post_alert(peer_blocked_alert(m_torrent->get_handle(), remote.address()));
return 0;
}
@ -1062,7 +1066,7 @@ namespace libtorrent
if (ses.m_ip_filter.access(remote.address()) & ip_filter::blocked)
{
if (ses.m_alerts.should_post<peer_blocked_alert>())
ses.m_alerts.post_alert(peer_blocked_alert(remote.address()));
ses.m_alerts.post_alert(peer_blocked_alert(m_torrent->get_handle(), remote.address()));
return 0;
}

View File

@ -1048,7 +1048,7 @@ namespace aux {
(*m_logger) << "filtered blocked ip\n";
#endif
if (m_alerts.should_post<peer_blocked_alert>())
m_alerts.post_alert(peer_blocked_alert(endp.address()));
m_alerts.post_alert(peer_blocked_alert(torrent_handle(), endp.address()));
return;
}

View File

@ -1543,7 +1543,7 @@ namespace libtorrent
debug_log("blocked ip from tracker: " + host->endpoint().address().to_string(ec));
#endif
if (m_ses.m_alerts.should_post<peer_blocked_alert>())
m_ses.m_alerts.post_alert(peer_blocked_alert(host->endpoint().address()));
m_ses.m_alerts.post_alert(peer_blocked_alert(get_handle(), host->endpoint().address()));
return;
}
@ -3111,7 +3111,7 @@ namespace libtorrent
if (m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked)
{
if (m_ses.m_alerts.should_post<peer_blocked_alert>())
m_ses.m_alerts.post_alert(peer_blocked_alert(a.address()));
m_ses.m_alerts.post_alert(peer_blocked_alert(get_handle(), a.address()));
return;
}
@ -3159,7 +3159,7 @@ namespace libtorrent
if (m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked)
{
if (m_ses.m_alerts.should_post<peer_blocked_alert>())
m_ses.m_alerts.post_alert(peer_blocked_alert(a.address()));
m_ses.m_alerts.post_alert(peer_blocked_alert(get_handle(), a.address()));
return;
}