Changeset 12120


Ignore:
Timestamp:
Mar 10, 2011, 11:46:22 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) use a hex key for tracker announces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r12096 r12120  
    5252    DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC = ( 60 * 2 ),
    5353
    54     /* the length of the 'key' argument passed in tracker requests */
    55     KEYLEN = 8,
    56 
    5754    /* how many web tasks we allow at one time */
    5855    MAX_CONCURRENT_TASKS = 48,
     
    127124    struct event * upkeepTimer;
    128125    int slotsAvailable;
     126    int key;
    129127    time_t lpdHouseKeepingAt;
    130128}
     
    177175    a = tr_new0( tr_announcer, 1 );
    178176    a->stops = TR_PTR_ARRAY_INIT;
     177    a->key = tr_cryptoRandInt( INT_MAX );
    179178    a->session = session;
    180179    a->slotsAvailable = MAX_CONCURRENT_TASKS;
     
    225224
    226225    uint32_t id;
    227 
    228     /* Sent as the "key" argument in tracker requests
    229      * to verify us if our IP address changes.
    230      * This is immutable for the life of the tracker object.
    231      * The +1 is for '\0' */
    232     unsigned char key_param[KEYLEN + 1];
    233226}
    234227tr_tracker_item;
    235 
    236 static void
    237 generateKeyParam( unsigned char * msg, size_t msglen )
    238 {
    239     size_t i;
    240     const char * pool = "abcdefghijklmnopqrstuvwxyz0123456789";
    241     const int poolSize = 36;
    242 
    243     tr_cryptoRandBuf( msg, msglen );
    244     for( i=0; i<msglen; ++i )
    245         msg[i] = pool[ msg[i] % poolSize ];
    246     msg[msglen] = '\0';
    247 }
    248228
    249229static tr_tracker_item*
     
    257237    tracker->scrape = tr_strdup( scrape );
    258238    tracker->id = id;
    259     generateKeyParam( tracker->key_param, KEYLEN );
    260239    tracker->seederCount = -1;
    261240    tracker->leecherCount = -1;
     
    602581                              "&left=%" PRIu64
    603582                              "&numwant=%d"
    604                               "&key=%s"
     583                              "&key=%x"
    605584                              "&compact=1"
    606585                              "&supportcrypto=1",
     
    614593                              tr_cpLeftUntilComplete( &torrent->completion ),
    615594                              numwant,
    616                               tracker->key_param );
     595                              announcer->key );
    617596
    618597    if( announcer->session->encryptionMode == TR_ENCRYPTION_REQUIRED )
     
    17241703    t->downloadCount = o->downloadCount;
    17251704    t->downloaderCount = o->downloaderCount;
    1726     memcpy( t->key_param, o->key_param, sizeof( t->key_param ) );
    17271705}
    17281706
Note: See TracChangeset for help on using the changeset viewer.