added option to deliberately corrupt data from certain peers, to test the case when hash fails occurs

This commit is contained in:
Arvid Norberg 2008-06-23 15:37:24 +00:00
parent c210b11b80
commit 964e8b93d0
1 changed files with 11 additions and 0 deletions

View File

@ -53,6 +53,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_type.hpp"
#include "libtorrent/assert.hpp"
//#define TORRENT_CORRUPT_DATA
using boost::bind;
using boost::shared_ptr;
using libtorrent::aux::session_impl;
@ -1447,6 +1449,15 @@ namespace libtorrent
TORRENT_ASSERT(!m_disk_recv_buffer);
TORRENT_ASSERT(m_disk_recv_buffer_size == 0);
#ifdef TORRENT_CORRUPT_DATA
// corrupt all pieces from certain peers
if (m_remote.address().is_v4()
&& (m_remote.address().to_v4().to_ulong() & 0xf) == 0)
{
data.get()[0] = ~data.get()[0];
}
#endif
#ifndef TORRENT_DISABLE_EXTENSIONS
for (extension_list_t::iterator i = m_extensions.begin()
, end(m_extensions.end()); i != end; ++i)