Changeset 7267


Ignore:
Timestamp:
Dec 4, 2008, 5:31:13 AM (12 years ago)
Author:
charles
Message:

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

Location:
branches/1.4x/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4x/libtransmission/handshake.c

    r7176 r7267  
    205205                       int *          setme_len )
    206206{
    207     uint8_t *      buf = tr_new0( uint8_t, HANDSHAKE_SIZE );
    208     uint8_t *      walk = buf;
    209     const uint8_t * torrentHash = tr_cryptoGetTorrentHash(
    210         handshake->crypto );
    211     const uint8_t * peerId = tr_getPeerId( );
     207    uint8_t          * buf = tr_new0( uint8_t, HANDSHAKE_SIZE );
     208    uint8_t          * walk = buf;
     209    const uint8_t    * torrentHash = tr_cryptoGetTorrentHash( handshake->crypto );
     210    const tr_torrent * tor = tr_torrentFindFromHash( handshake->handle, torrentHash );
     211    const uint8_t    * peerId = tor && tor->peer_id ? tor->peer_id : tr_getPeerId( );
    212212
    213213    memcpy( walk, HANDSHAKE_NAME, HANDSHAKE_NAME_LEN );
     
    682682        if( !tr_torrentExists( handshake->handle, hash ) )
    683683        {
    684             dbgmsg(
    685                 handshake,
    686                 "peer is trying to connect to us for a torrent we don't have." );
     684            dbgmsg( handshake, "peer is trying to connect to us for a torrent we don't have." );
    687685            return tr_handshakeDone( handshake, FALSE );
    688686        }
     
    705703
    706704    /**
    707     ***  If this is an incoming message, then we need to send a response
    708     ***handshake
     705    ***  If it's an incoming message, we need to send a response handshake
    709706    **/
    710707
  • branches/1.4x/libtransmission/torrent.h

    r7176 r7267  
    182182    uint8_t                  obfuscatedHash[SHA_DIGEST_LENGTH];
    183183
     184    /* If the initiator of the connection receives a handshake in which the
     185     * peer_id does not match the expected peerid, then the initiator is
     186     * expected to drop the connection. Note that the initiator presumably
     187     * received the peer information from the tracker, which includes the
     188     * peer_id that was registered by the peer. The peer_id from the tracker
     189     * and in the handshake are expected to match.
     190     */
     191    uint8_t * peer_id;
     192
    184193    /* Where to download */
    185     char *  downloadDir;
     194    char * downloadDir;
    186195
    187196    /* How many bytes we ask for per request */
  • branches/1.4x/libtransmission/tracker.c

    r7100 r7267  
    10761076    if( t && !t->isRunning )
    10771077    {
     1078        tr_torrent * tor;
     1079
     1080        /* change the peer-id */
    10781081        tr_free( t->peer_id );
    10791082        t->peer_id = tr_peerIdNew( );
     1083        if(( tor = tr_torrentFindFromHash( t->session, t->hash ))) {
     1084            tr_free( tor->peer_id );
     1085            tor->peer_id = (uint8_t*) tr_strdup( t->peer_id );
     1086        }
    10801087
    10811088        t->isRunning = 1;
Note: See TracChangeset for help on using the changeset viewer.