diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp index 44fff9c36..fd48588e1 100644 --- a/include/libtorrent/extensions.hpp +++ b/include/libtorrent/extensions.hpp @@ -149,6 +149,12 @@ namespace libtorrent virtual bool on_cancel(peer_request const& req) { return false; } + virtual bool on_reject(peer_request const& req) + { return false; } + + virtual bool on_suggest(int index) + { return false; } + // called when an extended message is received. If returning true, // the message is not processed by any other plugin and if false // is returned the next plugin in the chain will receive it to diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index ad2102f0d..46fba2634 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -687,6 +687,14 @@ namespace libtorrent boost::shared_ptr t = m_torrent.lock(); assert(t); +#ifndef TORRENT_DISABLE_EXTENSIONS + for (extension_list_t::iterator i = m_extensions.begin() + , end(m_extensions.end()); i != end; ++i) + { + if ((*i)->on_reject(r)) return; + } +#endif + std::deque::iterator i = std::find_if( m_download_queue.begin(), m_download_queue.end() , bind(match_request, boost::cref(r), _1, t->block_size())); @@ -743,7 +751,7 @@ namespace libtorrent void peer_connection::incoming_suggest(int index) { INVARIANT_CHECK; - + #ifdef TORRENT_VERBOSE_LOGGING (*m_logger) << time_now_string() << " <== SUGGEST_PIECE [ piece: " << index << " ]\n"; @@ -751,6 +759,14 @@ namespace libtorrent boost::shared_ptr t = m_torrent.lock(); if (!t) return; +#ifndef TORRENT_DISABLE_EXTENSIONS + for (extension_list_t::iterator i = m_extensions.begin() + , end(m_extensions.end()); i != end; ++i) + { + if ((*i)->on_suggest(index)) return; + } +#endif + if (t->have_piece(index)) return; if (m_suggested_pieces.size() > 9)