From 3d7dc768da9e360f8496d5cd9a56014ff42adcb7 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 8 Jul 2012 22:47:25 +0000 Subject: [PATCH] use random peer IDs in anonymous mode --- ChangeLog | 1 + include/libtorrent/session_settings.hpp | 3 ++- src/bt_peer_connection.cpp | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f337086b..00c64e726 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * use random peer IDs in anonymous mode * fix move_storage bugs * fix unnecessary dependency on boost.date_time when building boost.asio as separate compilation * always use SO_REUSEADDR and deprecate the flag to turn it on diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index bbbd65aaa..68744c0dd 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -757,10 +757,11 @@ namespace libtorrent // we have none of the files and go straight to download bool no_recheck_incomplete_resume; - // when this is true, libtorrent will take actions to make sure any + // when this is true, libtorrent will take actions to make sure no // privacy sensitive information is leaked out from the client. This // mode is assumed to be combined with using a proxy for all your // traffic. With this option, your true IP address will not be exposed + // nor anything that can tie your connection to your true IP bool anonymous_mode; // the number of milliseconds between internal ticks. Should be no diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 9dbfa45ee..d7a449326 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -755,8 +755,18 @@ namespace libtorrent ptr += 20; // peer id - memcpy(ptr, &m_ses.get_peer_id()[0], 20); -// ptr += 20; + if (m_ses.m_settings.anonymous_mode) + { + // in anonymous mode, every peer connection + // has a unique peer-id + for (int i = 0; i < 20; ++i) + *ptr++ = rand(); + } + else + { + memcpy(ptr, &m_ses.get_peer_id()[0], 20); +// ptr += 20; + } #ifdef TORRENT_VERBOSE_LOGGING peer_log("==> HANDSHAKE [ ih: %s ]", to_hex(ih.to_string()).c_str());