diff --git a/docs/manual.rst b/docs/manual.rst index 571f36af9..2dbebede5 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -5423,7 +5423,7 @@ address that was blocked. :: - struct peer_blocked_alert: alert + struct peer_blocked_alert: torrent_alert { // ... address ip; diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index de3b1abf8..f0aac9316 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -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); } }; diff --git a/src/policy.cpp b/src/policy.cpp index d114678d7..6bd11d65f 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -306,14 +306,14 @@ namespace libtorrent { (*i)->connection->disconnect(error_code(errors::banned_by_ip_filter, libtorrent_category)); if (ses.m_alerts.should_post()) - 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()) - 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()) + 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()) - 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()) - 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; } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index fdc024e08..e65b4bde2 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1048,7 +1048,7 @@ namespace aux { (*m_logger) << "filtered blocked ip\n"; #endif if (m_alerts.should_post()) - m_alerts.post_alert(peer_blocked_alert(endp.address())); + m_alerts.post_alert(peer_blocked_alert(torrent_handle(), endp.address())); return; } diff --git a/src/torrent.cpp b/src/torrent.cpp index 3680dfa30..88c4f123b 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -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()) - 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()) - 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()) - 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; }