mirror of
https://github.com/transmission/transmission
synced 2025-02-22 22:20:39 +00:00
(trunk, libT) filter out unsupported announce addresses
This commit is contained in:
parent
0796b7d977
commit
b9a4f418ed
1 changed files with 23 additions and 6 deletions
|
@ -693,10 +693,26 @@ createAnnounceURL( const tr_announcer * announcer,
|
||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
static tr_bool
|
||||||
|
announceURLIsSupported( const char * announce )
|
||||||
|
{
|
||||||
|
return ( announce != NULL )
|
||||||
|
&& ( ( strstr( announce, "http://" ) == announce ) ||
|
||||||
|
( strstr( announce, "https://" ) == announce ) );
|
||||||
|
}
|
||||||
|
|
||||||
tr_torrent_tiers *
|
tr_torrent_tiers *
|
||||||
tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor )
|
tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor )
|
||||||
{
|
{
|
||||||
|
int i, n;
|
||||||
tr_torrent_tiers * tiers;
|
tr_torrent_tiers * tiers;
|
||||||
|
tr_tracker_info ** infos;
|
||||||
|
|
||||||
|
/* get the trackers that we support... */
|
||||||
|
infos = tr_new( tr_tracker_info*, tor->info.trackerCount );
|
||||||
|
for( i=n=0; i<tor->info.trackerCount; ++i )
|
||||||
|
if( announceURLIsSupported( tor->info.trackers[i].announce ) )
|
||||||
|
infos[n++] = &tor->info.trackers[i];
|
||||||
|
|
||||||
assert( announcer != NULL );
|
assert( announcer != NULL );
|
||||||
assert( tr_isTorrent( tor ) );
|
assert( tr_isTorrent( tor ) );
|
||||||
|
@ -704,18 +720,19 @@ tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor )
|
||||||
tiers = tiersNew( );
|
tiers = tiersNew( );
|
||||||
|
|
||||||
/* build our private table of tiers... */
|
/* build our private table of tiers... */
|
||||||
if( tor->info.trackerCount )
|
if( n > 0 )
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int tierIndex = -1;
|
int tierIndex = -1;
|
||||||
tr_tier * tier = NULL;
|
tr_tier * tier = NULL;
|
||||||
|
|
||||||
for( i=0; i<tor->info.trackerCount; ++i )
|
for( i=0; i<tor->info.trackerCount; ++i )
|
||||||
{
|
{
|
||||||
if( tor->info.trackers[i].tier != tierIndex )
|
const tr_tracker_info * info = infos[i];
|
||||||
|
|
||||||
|
if( info->tier != tierIndex )
|
||||||
tier = NULL;
|
tier = NULL;
|
||||||
|
|
||||||
tierIndex = tor->info.trackers[i].tier;
|
tierIndex = info->tier;
|
||||||
|
|
||||||
if( tier == NULL ) {
|
if( tier == NULL ) {
|
||||||
tier = tierNew( tor );
|
tier = tierNew( tor );
|
||||||
|
@ -723,11 +740,11 @@ tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor )
|
||||||
tr_ptrArrayAppend( &tiers->tiers, tier );
|
tr_ptrArrayAppend( &tiers->tiers, tier );
|
||||||
}
|
}
|
||||||
|
|
||||||
tierAddTracker( announcer, tier, tor->info.trackers[i].announce,
|
tierAddTracker( announcer, tier, info->announce, info->scrape );
|
||||||
tor->info.trackers[i].scrape );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr_free( infos );
|
||||||
return tiers;
|
return tiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue