1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-04 02:28:03 +00:00

(libT) #1557: handshake peer-id doesn't match the peer-id sent in the tracker announce

This commit is contained in:
Charles Kerr 2008-12-04 05:27:59 +00:00
parent 223deaf2b6
commit 5d36543c40
3 changed files with 24 additions and 11 deletions

View file

@ -203,11 +203,11 @@ static uint8_t *
buildHandshakeMessage( tr_handshake * handshake,
int * setme_len )
{
uint8_t * buf = tr_new0( uint8_t, HANDSHAKE_SIZE );
uint8_t * walk = buf;
const uint8_t * torrentHash = tr_cryptoGetTorrentHash(
handshake->crypto );
const uint8_t * peerId = tr_getPeerId( );
uint8_t * buf = tr_new0( uint8_t, HANDSHAKE_SIZE );
uint8_t * walk = buf;
const uint8_t * torrentHash = tr_cryptoGetTorrentHash( handshake->crypto );
const tr_torrent * tor = tr_torrentFindFromHash( handshake->handle, torrentHash );
const uint8_t * peerId = tor && tor->peer_id ? tor->peer_id : tr_getPeerId( );
memcpy( walk, HANDSHAKE_NAME, HANDSHAKE_NAME_LEN );
walk += HANDSHAKE_NAME_LEN;
@ -665,9 +665,7 @@ readHandshake( tr_handshake * handshake,
{
if( !tr_torrentExists( handshake->handle, hash ) )
{
dbgmsg(
handshake,
"peer is trying to connect to us for a torrent we don't have." );
dbgmsg( handshake, "peer is trying to connect to us for a torrent we don't have." );
return tr_handshakeDone( handshake, FALSE );
}
else
@ -688,8 +686,7 @@ readHandshake( tr_handshake * handshake,
}
/**
*** If this is an incoming message, then we need to send a response
***handshake
*** If it's an incoming message, we need to send a response handshake
**/
if( !handshake->haveSentBitTorrentHandshake )

View file

@ -181,8 +181,17 @@ struct tr_torrent
uint8_t obfuscatedHash[SHA_DIGEST_LENGTH];
/* If the initiator of the connection receives a handshake in which the
* peer_id does not match the expected peerid, then the initiator is
* expected to drop the connection. Note that the initiator presumably
* received the peer information from the tracker, which includes the
* peer_id that was registered by the peer. The peer_id from the tracker
* and in the handshake are expected to match.
*/
uint8_t * peer_id;
/* Where to download */
char * downloadDir;
char * downloadDir;
/* How many bytes we ask for per request */
uint32_t blockSize;

View file

@ -1091,8 +1091,15 @@ tr_trackerStart( tr_tracker * t )
{
if( t && !t->isRunning )
{
tr_torrent * tor;
/* change the peer-id */
tr_free( t->peer_id );
t->peer_id = tr_peerIdNew( );
if(( tor = tr_torrentFindFromHash( t->session, t->hash ))) {
tr_free( tor->peer_id );
tor->peer_id = (uint8_t*) tr_strdup( t->peer_id );
}
t->isRunning = 1;
enqueueRequest( t->session, t, TR_REQ_STARTED );