added anonymous mode to disable some particular features that might give away the user's and the client's identity
This commit is contained in:
@@ -306,7 +306,9 @@ namespace aux {
|
||||
TORRENT_SETTING(boolean, strict_end_game_mode)
|
||||
TORRENT_SETTING(integer, default_peer_upload_rate)
|
||||
TORRENT_SETTING(integer, default_peer_download_rate)
|
||||
TORRENT_SETTING(boolean, broadcast_lsd)
|
||||
TORRENT_SETTING(boolean, ignore_resume_timestamps)
|
||||
TORRENT_SETTING(boolean, anonymous_mode)
|
||||
};
|
||||
|
||||
#undef TORRENT_SETTING
|
||||
@@ -709,17 +711,7 @@ namespace aux {
|
||||
, print.begin() + print.length()
|
||||
, m_peer_id.begin());
|
||||
|
||||
// http-accepted characters:
|
||||
// excluding ', since some buggy trackers don't support that
|
||||
static char const printable[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz-_.!~*()";
|
||||
|
||||
// the random number
|
||||
for (unsigned char* i = m_peer_id.begin() + print.length();
|
||||
i != m_peer_id.end(); ++i)
|
||||
{
|
||||
*i = printable[rand() % (sizeof(printable)-1)];
|
||||
}
|
||||
url_random((char*)&m_peer_id[print.length()], (char*)&m_peer_id[0] + 20);
|
||||
|
||||
m_timer.expires_from_now(milliseconds(100), ec);
|
||||
m_timer.async_wait(bind(&session_impl::on_tick, this, _1));
|
||||
@@ -1229,7 +1221,31 @@ namespace aux {
|
||||
|| m_settings.active_limit != s.active_limit)
|
||||
&& m_auto_manage_time_scaler > 2)
|
||||
m_auto_manage_time_scaler = 2;
|
||||
|
||||
// if anonymous mode was enabled, clear out the peer ID
|
||||
bool anonymous = (m_settings.anonymous_mode != s.anonymous_mode && s.anonymous_mode);
|
||||
|
||||
m_settings = s;
|
||||
|
||||
// enable anonymous mode. We don't want to accept any incoming
|
||||
// connections, except through a proxy.
|
||||
if (anonymous)
|
||||
{
|
||||
m_settings.user_agent.clear();
|
||||
url_random((char*)&m_peer_id[0], (char*)&m_peer_id[0] + 20);
|
||||
stop_lsd();
|
||||
stop_upnp();
|
||||
stop_natpmp();
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
stop_dht();
|
||||
#endif
|
||||
// close the listen sockets
|
||||
error_code ec;
|
||||
for (std::list<listen_socket_t>::iterator i = m_listen_sockets.begin()
|
||||
, end(m_listen_sockets.end()); i != end; ++i)
|
||||
i->sock->close(ec);
|
||||
m_listen_sockets.clear();
|
||||
}
|
||||
if (m_settings.connection_speed < 0) m_settings.connection_speed = 200;
|
||||
if (m_settings.broadcast_lsd && m_lsd)
|
||||
m_lsd->use_broadcast(true);
|
||||
@@ -1465,7 +1481,9 @@ namespace aux {
|
||||
|
||||
socks5_stream& s = *m_socks_listen_socket->get<socks5_stream>();
|
||||
s.set_command(2); // 2 means BIND (as opposed to CONNECT)
|
||||
s.async_connect(tcp::endpoint(address_v4::any(), m_listen_interface.port())
|
||||
m_socks_listen_port = m_listen_interface.port();
|
||||
if (m_socks_listen_port == 0) m_socks_listen_port = 2000 + rand() % 60000;
|
||||
s.async_connect(tcp::endpoint(address_v4::any(), m_socks_listen_port)
|
||||
, boost::bind(&session_impl::on_socks_accept, this, m_socks_listen_socket, _1));
|
||||
}
|
||||
|
||||
@@ -3173,6 +3191,17 @@ namespace aux {
|
||||
|
||||
unsigned short session_impl::listen_port() const
|
||||
{
|
||||
// if peer connections are set up to be received over a socks
|
||||
// proxy, and it's the same one as we're using for the tracker
|
||||
// just tell the tracker the socks5 port we're listening on
|
||||
if (m_socks_listen_socket->is_open()
|
||||
&& m_peer_proxy.hostname == m_tracker_proxy.hostname)
|
||||
return m_socks_listen_port;
|
||||
|
||||
// if not, don't tell the tracker anything if we're in anonymous
|
||||
// mode. We don't want to leak our listen port since it can
|
||||
// potentially identify us if it is leaked elsewere
|
||||
if (m_settings.anonymous_mode) return 0;
|
||||
if (m_listen_sockets.empty()) return 0;
|
||||
return m_listen_sockets.front().external_port;
|
||||
}
|
||||
|
Reference in New Issue
Block a user