From 5cf8aa57f496922d02022f99377eee4a88efbd32 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 19 Feb 2013 08:14:16 +0000 Subject: [PATCH] anonymous mode should default to false. minor fixes --- src/piece_picker.cpp | 2 +- src/session.cpp | 2 +- src/session_impl.cpp | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 72d24e53b..1d522f15e 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -1828,7 +1828,7 @@ namespace libtorrent int piece_picker::blocks_in_piece(int index) const { TORRENT_ASSERT(index >= 0); - TORRENT_ASSERT(index < (int)m_piece_map.size()); + TORRENT_ASSERT(index < (int)m_piece_map.size() || m_piece_map.empty()); if (index+1 == (int)m_piece_map.size()) return m_blocks_in_last_piece; else diff --git a/src/session.cpp b/src/session.cpp index db8673151..2fc66d3ea 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -1247,7 +1247,7 @@ namespace libtorrent , max_pex_peers(50) , ignore_resume_timestamps(false) , no_recheck_incomplete_resume(false) - , anonymous_mode(true) + , anonymous_mode(false) , force_proxy(false) , tick_interval(100) , report_web_seed_downloads(true) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 52f5899b2..2bcb2bf31 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2063,6 +2063,13 @@ namespace aux { if (connections_limit_changed) update_connections_limit(); if (unchoke_limit_changed) update_unchoke_limit(); + bool anonymous_mode = (m_settings.anonymous_mode != s.anonymous_mode && s.anonymous_mode); + if (anonymous_mode) + { + m_settings.user_agent.clear(); + url_random((char*)&m_peer_id[0], (char*)&m_peer_id[0] + 20); + } + bool force_proxy = (m_settings.force_proxy != s.force_proxy && s.force_proxy); m_udp_socket.set_force_proxy(s.force_proxy); @@ -2071,8 +2078,6 @@ namespace aux { // connections, except through a proxy. if (force_proxy) { - m_settings.user_agent.clear(); - url_random((char*)&m_peer_id[0], (char*)&m_peer_id[0] + 20); stop_lsd(); stop_upnp(); stop_natpmp();