Changeset 9229


Ignore:
Timestamp:
Oct 2, 2009, 2:03:30 AM (12 years ago)
Author:
charles
Message:

(trunk, libT) filter out unsupported announce addresses

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r9226 r9229  
    694694***/
    695695
     696static tr_bool
     697announceURLIsSupported( const char * announce )
     698{
     699    return ( announce != NULL )
     700        && ( ( strstr( announce, "http://" ) == announce ) ||
     701             ( strstr( announce, "https://" ) == announce ) );
     702}
     703
    696704tr_torrent_tiers *
    697705tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor )
    698706{
     707    int i, n;
    699708    tr_torrent_tiers * tiers;
     709    tr_tracker_info ** infos;
     710
     711    /* get the trackers that we support... */
     712    infos = tr_new( tr_tracker_info*, tor->info.trackerCount );
     713    for( i=n=0; i<tor->info.trackerCount; ++i )
     714        if( announceURLIsSupported( tor->info.trackers[i].announce ) )
     715            infos[n++] = &tor->info.trackers[i];
    700716
    701717    assert( announcer != NULL );
     
    705721
    706722    /* build our private table of tiers... */
    707     if( tor->info.trackerCount )
     723    if( n > 0 )
    708724    {
    709         int i;
    710725        int tierIndex = -1;
    711726        tr_tier * tier = NULL;
     
    713728        for( i=0; i<tor->info.trackerCount; ++i )
    714729        {
    715             if( tor->info.trackers[i].tier != tierIndex )
     730            const tr_tracker_info * info = infos[i];
     731
     732            if( info->tier != tierIndex )
    716733                tier = NULL;
    717734
    718             tierIndex = tor->info.trackers[i].tier;
     735            tierIndex = info->tier;
    719736
    720737            if( tier == NULL ) {
     
    724741            }
    725742
    726             tierAddTracker( announcer, tier, tor->info.trackers[i].announce,
    727                                              tor->info.trackers[i].scrape );
    728         }
    729     }
    730 
     743            tierAddTracker( announcer, tier, info->announce, info->scrape );
     744        }
     745    }
     746
     747    tr_free( infos );
    731748    return tiers;
    732749}
Note: See TracChangeset for help on using the changeset viewer.