Changeset 7282


Ignore:
Timestamp:
Dec 5, 2008, 3:55:24 PM (12 years ago)
Author:
charles
Message:

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

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

Legend:

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

    r6489 r7282  
    172172                       int          * setme_len )
    173173{
    174     uint8_t * buf = tr_new0( uint8_t, HANDSHAKE_SIZE );
    175     uint8_t * walk = buf;
    176     const uint8_t * torrentHash = tr_cryptoGetTorrentHash( handshake->crypto );
    177     const uint8_t * peerId = tr_getPeerId( );
     174    uint8_t          * buf = tr_new0( uint8_t, HANDSHAKE_SIZE );
     175    uint8_t          * walk = buf;
     176    const uint8_t    * torrentHash = tr_cryptoGetTorrentHash( handshake->crypto );
     177    const tr_torrent * tor = tr_torrentFindFromHash( handshake->handle, torrentHash );
     178    const uint8_t    * peerId = tor && tor->peer_id ? tor->peer_id : tr_getPeerId( );
    178179
    179180    memcpy( walk, HANDSHAKE_NAME, HANDSHAKE_NAME_LEN );
  • branches/1.3x/libtransmission/torrent.h

    r6016 r7282  
    132132    uint8_t                    obfuscatedHash[SHA_DIGEST_LENGTH];
    133133
     134    /* If the initiator of the connection receives a handshake in which the
     135     * peer_id does not match the expected peerid, then the initiator is
     136     * expected to drop the connection. Note that the initiator presumably
     137     * received the peer information from the tracker, which includes the
     138     * peer_id that was registered by the peer. The peer_id from the tracker
     139     * and in the handshake are expected to match.
     140     */
     141    uint8_t * peer_id;
     142
    134143    /* Where to download */
    135144    char                     * downloadDir;
  • branches/1.3x/libtransmission/tracker.c

    r6759 r7282  
    968968    if( t && !t->isRunning )
    969969    {
     970        tr_torrent * tor;
     971
     972        /* change the peer-id */
    970973        tr_free( t->peer_id );
    971974        t->peer_id = tr_peerIdNew( );
     975        if(( tor = tr_torrentFindFromHash( t->session, t->hash ))) {
     976            tr_free( tor->peer_id );
     977            tor->peer_id = (uint8_t*) tr_strdup( t->peer_id );
     978        }
    972979
    973980        t->isRunning = 1;
Note: See TracChangeset for help on using the changeset viewer.