Changeset 7266


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

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

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r7234 r7266  
    204204                       int *          setme_len )
    205205{
    206     uint8_t *      buf = tr_new0( uint8_t, HANDSHAKE_SIZE );
    207     uint8_t *      walk = buf;
    208     const uint8_t * torrentHash = tr_cryptoGetTorrentHash(
    209         handshake->crypto );
    210     const uint8_t * peerId = tr_getPeerId( );
     206    uint8_t          * buf = tr_new0( uint8_t, HANDSHAKE_SIZE );
     207    uint8_t          * walk = buf;
     208    const uint8_t    * torrentHash = tr_cryptoGetTorrentHash( handshake->crypto );
     209    const tr_torrent * tor = tr_torrentFindFromHash( handshake->handle, torrentHash );
     210    const uint8_t    * peerId = tor && tor->peer_id ? tor->peer_id : tr_getPeerId( );
    211211
    212212    memcpy( walk, HANDSHAKE_NAME, HANDSHAKE_NAME_LEN );
     
    666666        if( !tr_torrentExists( handshake->handle, hash ) )
    667667        {
    668             dbgmsg(
    669                 handshake,
    670                 "peer is trying to connect to us for a torrent we don't have." );
     668            dbgmsg( handshake, "peer is trying to connect to us for a torrent we don't have." );
    671669            return tr_handshakeDone( handshake, FALSE );
    672670        }
     
    689687
    690688    /**
    691     ***  If this is an incoming message, then we need to send a response
    692     ***handshake
     689    ***  If it's an incoming message, we need to send a response handshake
    693690    **/
    694691
  • trunk/libtransmission/torrent.h

    r7251 r7266  
    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 */
  • trunk/libtransmission/tracker.c

    r7238 r7266  
    10921092    if( t && !t->isRunning )
    10931093    {
     1094        tr_torrent * tor;
     1095
     1096        /* change the peer-id */
    10941097        tr_free( t->peer_id );
    10951098        t->peer_id = tr_peerIdNew( );
     1099        if(( tor = tr_torrentFindFromHash( t->session, t->hash ))) {
     1100            tr_free( tor->peer_id );
     1101            tor->peer_id = (uint8_t*) tr_strdup( t->peer_id );
     1102        }
    10961103
    10971104        t->isRunning = 1;
Note: See TracChangeset for help on using the changeset viewer.