clean up peer-id in bt_peer_connection (for privacy mode) and reduce dependency on session

This commit is contained in:
Arvid Norberg 2014-04-22 23:37:21 +00:00
parent 3192e59a1a
commit f037704539
4 changed files with 12 additions and 8 deletions

View File

@ -90,6 +90,7 @@ namespace libtorrent
, boost::shared_ptr<socket_type> s
, tcp::endpoint const& remote
, policy::peer* peerinfo
, peer_id const& pid
, boost::weak_ptr<torrent> t = boost::weak_ptr<torrent>()
, bool outgoing = false);
@ -387,6 +388,9 @@ private:
static const message_handler m_message_handler[num_supported_messages];
// the peer ID we advertise for ourself
peer_id m_our_peer_id;
// this is a queue of ranges that describes
// where in the send buffer actual payload
// data is located. This is currently

View File

@ -101,6 +101,7 @@ namespace libtorrent
, shared_ptr<socket_type> s
, tcp::endpoint const& remote
, policy::peer* peerinfo
, peer_id const& pid
, boost::weak_ptr<torrent> tor
, bool outgoing)
: peer_connection(ses, tor, s, remote
@ -118,6 +119,7 @@ namespace libtorrent
, m_encrypted(false)
, m_rc4_encrypted(false)
#endif
, m_our_peer_id(pid)
#ifndef TORRENT_DISABLE_EXTENSIONS
, m_upload_only_id(0)
, m_holepunch_id(0)
@ -791,13 +793,11 @@ namespace libtorrent
// in anonymous mode, every peer connection
// has a unique peer-id
for (int i = 0; i < 20; ++i)
ptr[i] = random() & 0xff;
m_our_peer_id[i] = random() & 0xff;
}
else
{
memcpy(ptr, &m_ses.get_peer_id()[0], 20);
}
// ptr += 20;
memcpy(ptr, &m_our_peer_id[0], 20);
ptr += 20;
#ifdef TORRENT_VERBOSE_LOGGING
peer_log("==> HANDSHAKE [ ih: %s ]", to_hex(ih.to_string()).c_str());

View File

@ -2857,7 +2857,7 @@ retry:
setup_socket_buffers(*s);
boost::intrusive_ptr<peer_connection> c(
new bt_peer_connection(*this, s, endp, 0));
new bt_peer_connection(*this, s, endp, 0, get_peer_id()));
#if TORRENT_USE_ASSERTS
c->m_in_constructor = false;
#endif

View File

@ -5855,7 +5855,7 @@ namespace libtorrent
m_ses.setup_socket_buffers(*s);
boost::intrusive_ptr<peer_connection> c(new bt_peer_connection(
m_ses, s, a, peerinfo, shared_from_this(), true));
m_ses, s, a, peerinfo, m_ses.get_peer_id(), shared_from_this(), true));
#if TORRENT_USE_ASSERTS
c->m_in_constructor = false;