Changeset 3129


Ignore:
Timestamp:
Sep 22, 2007, 12:53:11 AM (15 years ago)
Author:
charles
Message:
  • abort connections if the peer selects an encryption option we didn't offer them.
  • fix a shutdown crash as a result of peer-mgr timers not getting destroyed.
  • remove some console messages.
Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r3128 r3129  
    257257}
    258258
     259static void
     260tr_handshakeDone( tr_handshake * handshake, int isConnected );
     261
    259262/***
    260263****
     
    291294    /* cleanup */
    292295    evbuffer_free( outbuf );
     296}
     297
     298static uint32_t
     299getCryptoProvide( const tr_handshake * handshake )
     300{
     301    uint32_t i = 0;
     302
     303    i |= CRYPTO_PROVIDE_CRYPTO; /* always allow crypto */
     304
     305    if( handshake->allowUnencryptedPeers ) /* sometimes allow plaintext */
     306        i |= CRYPTO_PROVIDE_PLAINTEXT;
     307
     308   return i;
    293309}
    294310
     
    365381
    366382        /* crypto_provide */
    367         crypto_provide = 0;
    368         crypto_provide |= CRYPTO_PROVIDE_CRYPTO; /* always allow crypto */
    369         if( handshake->allowUnencryptedPeers ) /* sometimes allow plaintext */
    370             crypto_provide |= CRYPTO_PROVIDE_PLAINTEXT;
    371         fprintf( stderr, "crypto_provide is %d\n", (int)crypto_provide );
    372 
     383        crypto_provide = getCryptoProvide( handshake );
    373384        crypto_provide = htonl( crypto_provide );
    374385        tr_cryptoEncrypt( handshake->crypto, sizeof(crypto_provide), &crypto_provide, &crypto_provide );
     
    457468
    458469    tr_peerIoReadUint32( handshake->io, inbuf, &crypto_select );
    459     assert( crypto_select==1 || crypto_select==2 );
    460470    handshake->crypto_select = crypto_select;
    461471    dbgmsg( handshake, "crypto select is %d", (int)crypto_select );
     472    if( ! ( crypto_select & getCryptoProvide( handshake ) ) )
     473    {
     474        dbgmsg( handshake, "peer selected an encryption option we didn't provide" );
     475        tr_handshakeDone( handshake, FALSE );
     476        return READ_DONE;
     477    }
    462478
    463479    tr_peerIoReadUint16( handshake->io, inbuf, &pad_d_len );
     
    496512****
    497513***/
    498 
    499 static void
    500 tr_handshakeDone( tr_handshake * handshake, int isConnected );
    501514
    502515static int
  • trunk/libtransmission/peer-mgr.c

    r3127 r3129  
    224224    memcpy( hash, t->hash, SHA_DIGEST_LENGTH );
    225225
     226    tr_timerFree( &t->reconnectTimer );
     227    tr_timerFree( &t->reconnectSoonTimer );
    226228    tr_timerFree( &t->rechokeTimer );
    227229    tr_timerFree( &t->rechokeSoonTimer );
     
    11621164
    11631165static int
    1164 reconnectPulse( void * vt )
    1165 {
    1166     static int n = 0;
     1166reconnectPulse( void * vt UNUSED )
     1167{
     1168#if 0
    11671169    Torrent * t = vt;
    1168     fprintf( stderr, "when this code is written, it will cull out crappy peer connections and initiate new ones within some limit. %p - %d\n", t, ++n );
     1170    /* FIXME */
     1171#endif
    11691172    return TRUE;
    11701173}
Note: See TracChangeset for help on using the changeset viewer.