2007-08-16 20:00:06 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2007 Charles Kerr <charles@rebelbase.com>
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
2007-08-16 20:00:06 +00:00
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
2007-08-18 17:19:49 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
2007-08-16 20:00:06 +00:00
|
|
|
*/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-09 20:07:52 +00:00
|
|
|
#include <assert.h>
|
2007-08-16 20:00:06 +00:00
|
|
|
#include <ctype.h> /* isalnum */
|
|
|
|
#include <stdio.h> /* snprintf */
|
2007-07-29 18:11:21 +00:00
|
|
|
#include <stdlib.h>
|
2007-08-16 20:00:06 +00:00
|
|
|
#include <string.h> /* strcmp, strchr */
|
2007-10-22 18:52:36 +00:00
|
|
|
#include <libgen.h> /* basename */
|
2007-07-29 18:11:21 +00:00
|
|
|
|
2007-11-07 18:26:19 +00:00
|
|
|
#include <sys/queue.h> /* evhttp.h needs this */
|
2007-08-16 20:00:06 +00:00
|
|
|
#include <event.h>
|
|
|
|
#include <evhttp.h>
|
2007-07-14 16:29:21 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#include "transmission.h"
|
2007-07-09 20:10:42 +00:00
|
|
|
#include "bencode.h"
|
2007-07-30 18:04:10 +00:00
|
|
|
#include "completion.h"
|
2007-11-29 00:43:58 +00:00
|
|
|
#include "list.h"
|
2007-07-09 20:10:42 +00:00
|
|
|
#include "net.h"
|
2007-08-16 20:00:06 +00:00
|
|
|
#include "publish.h"
|
2007-09-21 05:31:29 +00:00
|
|
|
#include "shared.h"
|
2007-07-30 18:04:10 +00:00
|
|
|
#include "tracker.h"
|
2007-08-18 03:02:32 +00:00
|
|
|
#include "trevent.h"
|
2007-07-30 18:04:10 +00:00
|
|
|
#include "utils.h"
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
enum
|
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
/* seconds between tracker pulses */
|
|
|
|
PULSE_INTERVAL_SEC = 1,
|
|
|
|
|
|
|
|
/* maximum number of concurrent tracker socket connections */
|
|
|
|
MAX_TRACKER_SOCKETS = 16,
|
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
/* unless the tracker says otherwise, rescrape this frequently */
|
|
|
|
DEFAULT_SCRAPE_INTERVAL_SEC = (60 * 15),
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
/* unless the tracker says otherwise, this is the announce interval */
|
|
|
|
DEFAULT_ANNOUNCE_INTERVAL_SEC = (60 * 4),
|
2007-10-17 01:17:30 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
/* unless the tracker says otherwise, this is the announce min_interval */
|
|
|
|
DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC = (60 * 2),
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
/* this is how long we'll leave a request hanging before timeout */
|
|
|
|
TIMEOUT_INTERVAL_SEC = 45,
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
/* this is how long we'll leave a 'stop' request hanging before timeout.
|
|
|
|
we wait less time for this so it doesn't slow down shutdowns */
|
|
|
|
STOP_TIMEOUT_INTERVAL_SEC = 5,
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
/* the value of the 'numwant' argument passed in tracker requests. */
|
|
|
|
NUMWANT = 200,
|
2007-07-30 17:11:00 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
/* the length of the 'key' argument passed in tracker requests */
|
|
|
|
KEYLEN = 10
|
|
|
|
};
|
2006-12-17 16:36:27 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
2007-07-30 17:11:00 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TR_REQ_STARTED,
|
|
|
|
TR_REQ_COMPLETED,
|
|
|
|
TR_REQ_STOPPED,
|
|
|
|
TR_REQ_REANNOUNCE,
|
|
|
|
TR_REQ_COUNT
|
|
|
|
};
|
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
struct tr_tracker
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-09-20 20:14:13 +00:00
|
|
|
tr_handle * handle;
|
2007-08-18 03:02:32 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
/* these are set from the latest scrape or tracker response */
|
2007-10-17 01:17:30 +00:00
|
|
|
int announceIntervalSec;
|
2007-10-17 18:59:58 +00:00
|
|
|
int announceMinIntervalSec;
|
2007-10-17 01:17:30 +00:00
|
|
|
int scrapeIntervalSec;
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_tracker_info * redirect;
|
|
|
|
tr_tracker_info * addresses;
|
2007-08-16 20:00:06 +00:00
|
|
|
int addressIndex;
|
|
|
|
int addressCount;
|
|
|
|
int * tierFronts;
|
|
|
|
|
|
|
|
/* sent as the "key" argument in tracker requests
|
|
|
|
to verify us if our IP address changes.
|
|
|
|
This is immutable for the life of the tracker object. */
|
2007-10-17 18:59:58 +00:00
|
|
|
char key_param[KEYLEN+1];
|
2007-08-16 20:00:06 +00:00
|
|
|
|
|
|
|
tr_publisher_t * publisher;
|
2006-12-17 16:36:27 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
/* torrent hash string */
|
|
|
|
uint8_t hash[SHA_DIGEST_LENGTH];
|
|
|
|
char escaped[SHA_DIGEST_LENGTH * 3 + 1];
|
2007-10-04 19:58:30 +00:00
|
|
|
char * name;
|
2007-04-08 05:41:44 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
/* corresponds to the peer_id sent as a tracker request parameter.
|
2007-10-23 14:00:17 +00:00
|
|
|
one tracker admin says: "When the same torrent is opened and
|
2007-08-16 20:00:06 +00:00
|
|
|
closed and opened again without quitting Transmission ...
|
|
|
|
change the peerid. It would help sometimes if a stopped event
|
|
|
|
was missed to ensure that we didn't think someone was cheating. */
|
|
|
|
char peer_id[TR_ID_LEN + 1];
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
/* these are set from the latest tracker response... -1 is 'unknown' */
|
2007-08-16 20:00:06 +00:00
|
|
|
int timesDownloaded;
|
2007-10-17 18:59:58 +00:00
|
|
|
int seederCount;
|
|
|
|
int leecherCount;
|
2007-08-16 20:00:06 +00:00
|
|
|
char * trackerID;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
/* the last tracker request we sent. (started, stopped, etc.)
|
|
|
|
automatic announces are an empty string;
|
|
|
|
NULL means no message has ever been sent */
|
|
|
|
char * lastRequest;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-10-17 01:17:30 +00:00
|
|
|
time_t manualAnnounceAllowedAt;
|
2007-11-29 00:43:58 +00:00
|
|
|
time_t reannounceAt;
|
|
|
|
time_t scrapeAt;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
unsigned int isRunning : 1;
|
2007-10-17 18:59:58 +00:00
|
|
|
};
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-10-18 03:55:55 +00:00
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
|
|
|
static void
|
|
|
|
myDebug( const char * file, int line, const tr_tracker * t, const char * fmt, ... )
|
|
|
|
{
|
|
|
|
FILE * fp = tr_getLog( );
|
|
|
|
if( fp != NULL )
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
char timestr[64];
|
2007-10-22 18:52:36 +00:00
|
|
|
struct evbuffer * buf = evbuffer_new( );
|
|
|
|
char * myfile = tr_strdup( file );
|
|
|
|
|
2007-10-18 03:55:55 +00:00
|
|
|
evbuffer_add_printf( buf, "[%s] ", tr_getLogTimeStr( timestr, sizeof(timestr) ) );
|
|
|
|
if( t != NULL )
|
|
|
|
evbuffer_add_printf( buf, "%s ", t->name );
|
|
|
|
va_start( args, fmt );
|
|
|
|
evbuffer_add_vprintf( buf, fmt, args );
|
|
|
|
va_end( args );
|
2007-10-22 18:52:36 +00:00
|
|
|
evbuffer_add_printf( buf, " (%s:%d)\n", basename(myfile), line );
|
2007-10-18 03:55:55 +00:00
|
|
|
fwrite( EVBUFFER_DATA(buf), 1, EVBUFFER_LENGTH(buf), fp );
|
2007-10-22 18:52:36 +00:00
|
|
|
|
|
|
|
tr_free( myfile );
|
2007-10-18 03:55:55 +00:00
|
|
|
evbuffer_free( buf );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define dbgmsg(t, fmt...) myDebug(__FILE__, __LINE__, t, ##fmt )
|
|
|
|
|
2007-08-18 08:28:57 +00:00
|
|
|
/***
|
2007-11-29 00:43:58 +00:00
|
|
|
****
|
2007-08-18 08:28:57 +00:00
|
|
|
***/
|
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static tr_tracker_info *
|
|
|
|
getCurrentAddress( const tr_tracker * t )
|
|
|
|
{
|
|
|
|
assert( t->addresses != NULL );
|
|
|
|
assert( t->addressIndex >= 0 );
|
|
|
|
assert( t->addressIndex < t->addressCount );
|
|
|
|
|
|
|
|
return t->redirect ? t->redirect
|
|
|
|
: t->addresses + t->addressIndex;
|
|
|
|
}
|
|
|
|
|
2007-10-07 16:07:19 +00:00
|
|
|
static int
|
2007-11-29 00:43:58 +00:00
|
|
|
trackerSupportsScrape( const tr_tracker * t )
|
2007-08-18 08:28:57 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
const tr_tracker_info * info = getCurrentAddress( t );
|
|
|
|
|
|
|
|
return ( info != NULL )
|
|
|
|
&& ( info->scrape != NULL )
|
|
|
|
&& ( info->scrape[0] != '\0' );
|
2007-10-07 16:07:19 +00:00
|
|
|
}
|
2007-08-18 08:28:57 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
struct torrent_hash
|
2007-10-07 16:07:19 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_handle * handle;
|
|
|
|
uint8_t hash[SHA_DIGEST_LENGTH];
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct torrent_hash*
|
|
|
|
torrentHashNew( tr_handle * handle, const tr_tracker * t )
|
|
|
|
{
|
|
|
|
struct torrent_hash * data = tr_new( struct torrent_hash, 1 );
|
|
|
|
data->handle = handle;
|
|
|
|
memcpy( data->hash, t->hash, SHA_DIGEST_LENGTH );
|
|
|
|
return data;
|
2007-10-07 16:07:19 +00:00
|
|
|
}
|
2007-08-18 08:28:57 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_tracker *
|
|
|
|
findTrackerFromHash( struct torrent_hash * data )
|
2007-10-07 16:07:19 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_torrent * torrent = tr_torrentFindFromHash( data->handle, data->hash );
|
|
|
|
return torrent ? torrent->tracker : NULL;
|
2007-08-18 08:28:57 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
/***
|
|
|
|
**** PUBLISH
|
|
|
|
***/
|
2007-02-27 04:00:38 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
static const tr_tracker_event emptyEvent = { 0, NULL, NULL, NULL, 0 };
|
2007-08-16 20:00:06 +00:00
|
|
|
|
|
|
|
static void
|
2007-10-17 18:59:58 +00:00
|
|
|
publishMessage( tr_tracker * t, const char * msg, int type )
|
2007-08-16 20:00:06 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_tracker_event event = emptyEvent;
|
|
|
|
event.hash = t->hash;
|
2007-08-16 20:00:06 +00:00
|
|
|
event.messageType = type;
|
|
|
|
event.text = msg;
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_publisherPublish( t->publisher, t, &event );
|
2007-08-16 20:00:06 +00:00
|
|
|
}
|
2007-09-25 18:39:58 +00:00
|
|
|
|
|
|
|
static void
|
2007-10-17 18:59:58 +00:00
|
|
|
publishErrorClear( tr_tracker * t )
|
2007-09-25 18:39:58 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
publishMessage( t, NULL, TR_TRACKER_ERROR_CLEAR );
|
2007-09-25 18:39:58 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
static void
|
2007-10-17 18:59:58 +00:00
|
|
|
publishErrorMessage( tr_tracker * t, const char * msg )
|
2007-08-16 20:00:06 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
publishMessage( t, msg, TR_TRACKER_ERROR );
|
2007-08-16 20:00:06 +00:00
|
|
|
}
|
2007-09-25 18:39:58 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
static void
|
2007-10-17 18:59:58 +00:00
|
|
|
publishWarning( tr_tracker * t, const char * msg )
|
2007-08-16 20:00:06 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
publishMessage( t, msg, TR_TRACKER_WARNING );
|
2006-12-17 16:36:27 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
static void
|
2007-10-17 18:59:58 +00:00
|
|
|
publishNewPeers( tr_tracker * t, int count, uint8_t * peers )
|
2006-12-17 16:36:27 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_tracker_event event = emptyEvent;
|
|
|
|
event.hash = t->hash;
|
2007-08-16 20:00:06 +00:00
|
|
|
event.messageType = TR_TRACKER_PEERS;
|
|
|
|
event.peerCount = count;
|
|
|
|
event.peerCompact = peers;
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_inf( "Torrent \"%s\" got %d new peers", t->name, count );
|
|
|
|
tr_publisherPublish( t->publisher, t, &event );
|
2007-07-30 17:11:00 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
/***
|
2007-11-29 00:43:58 +00:00
|
|
|
****
|
2007-08-16 20:00:06 +00:00
|
|
|
***/
|
|
|
|
|
|
|
|
static void
|
2007-11-29 00:43:58 +00:00
|
|
|
onStoppedResponse( struct evhttp_request * req UNUSED, void * handle UNUSED )
|
2007-08-21 00:01:14 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
dbgmsg( NULL, "got a response to some `stop' message" );
|
2006-12-02 01:46:54 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
static int
|
|
|
|
parseBencResponse( struct evhttp_request * req, benc_val_t * setme )
|
2007-07-30 17:11:00 +00:00
|
|
|
{
|
2007-08-16 20:00:06 +00:00
|
|
|
const unsigned char * body = EVBUFFER_DATA( req->input_buffer );
|
|
|
|
const int bodylen = EVBUFFER_LENGTH( req->input_buffer );
|
|
|
|
int ret = 1;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i=0; ret && i<bodylen; ++i )
|
|
|
|
if( !tr_bencLoad( body+i, bodylen-1, setme, NULL ) )
|
|
|
|
ret = 0;
|
2007-10-17 18:59:58 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
return ret;
|
2007-07-30 17:11:00 +00:00
|
|
|
}
|
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
static const char*
|
|
|
|
updateAddresses( tr_tracker * t, const struct evhttp_request * req )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
const char * ret = NULL;
|
2007-08-16 20:00:06 +00:00
|
|
|
int moveToNextAddress = FALSE;
|
|
|
|
|
|
|
|
if( !req )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-10-26 16:39:00 +00:00
|
|
|
ret = "Tracker hasn't responded yet. Retrying...";
|
2007-08-18 06:06:53 +00:00
|
|
|
tr_inf( ret );
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
moveToNextAddress = TRUE;
|
|
|
|
}
|
|
|
|
else if( req->response_code == HTTP_OK )
|
|
|
|
{
|
|
|
|
if( t->redirect != NULL )
|
2006-12-17 16:36:27 +00:00
|
|
|
{
|
2007-08-16 20:00:06 +00:00
|
|
|
/* multitracker spec: "if a connection with a tracker is
|
|
|
|
successful, it will be moved to the front of the tier." */
|
|
|
|
const int i = t->addressIndex;
|
|
|
|
const int j = t->tierFronts[i];
|
2007-09-20 16:32:01 +00:00
|
|
|
const tr_tracker_info swap = t->addresses[i];
|
2007-08-21 20:38:34 +00:00
|
|
|
t->addresses[i] = t->addresses[j];
|
|
|
|
t->addresses[j] = swap;
|
2006-12-17 16:36:27 +00:00
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
else if( ( req->response_code == HTTP_MOVEPERM )
|
|
|
|
|| ( req->response_code == HTTP_MOVETEMP ) )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-08-16 20:00:06 +00:00
|
|
|
const char * loc = evhttp_find_header( req->input_headers, "Location" );
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_tracker_info tmp;
|
2007-08-16 20:00:06 +00:00
|
|
|
if( tr_trackerInfoInit( &tmp, loc, -1 ) ) /* a bad redirect? */
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-08-16 20:00:06 +00:00
|
|
|
moveToNextAddress = TRUE;
|
2006-12-02 01:46:54 +00:00
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
else if( req->response_code == HTTP_MOVEPERM )
|
2006-12-17 16:36:27 +00:00
|
|
|
{
|
2007-09-20 16:32:01 +00:00
|
|
|
tr_tracker_info * cur = &t->addresses[t->addressIndex];
|
2007-08-16 20:00:06 +00:00
|
|
|
tr_trackerInfoClear( cur );
|
|
|
|
*cur = tmp;
|
2006-12-17 16:36:27 +00:00
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
else if( req->response_code == HTTP_MOVETEMP )
|
2006-12-17 16:36:27 +00:00
|
|
|
{
|
2007-08-16 20:00:06 +00:00
|
|
|
if( t->redirect == NULL )
|
2007-09-20 16:32:01 +00:00
|
|
|
t->redirect = tr_new0( tr_tracker_info, 1 );
|
2007-08-16 20:00:06 +00:00
|
|
|
else
|
|
|
|
tr_trackerInfoClear( t->redirect );
|
|
|
|
*t->redirect = tmp;
|
2006-12-17 16:36:27 +00:00
|
|
|
}
|
2006-12-02 01:46:54 +00:00
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
moveToNextAddress = TRUE;
|
|
|
|
}
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
if( moveToNextAddress )
|
|
|
|
if ( ++t->addressIndex >= t->addressCount )
|
|
|
|
t->addressIndex = 0;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
return ret;
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/* Convert to compact form */
|
|
|
|
static uint8_t *
|
|
|
|
parseOldPeers( benc_val_t * bePeers, int * setmePeerCount )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
int i;
|
|
|
|
uint8_t *compact, *walk;
|
|
|
|
const int peerCount = bePeers->val.l.count;
|
2007-08-20 23:37:08 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
assert( bePeers->type == TYPE_LIST );
|
2007-08-20 23:37:08 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
compact = tr_new( uint8_t, peerCount*6 );
|
2007-08-20 23:37:08 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
for( i=0, walk=compact; i<peerCount; ++i )
|
|
|
|
{
|
|
|
|
struct in_addr addr;
|
|
|
|
tr_port_t port;
|
|
|
|
benc_val_t * val;
|
|
|
|
benc_val_t * peer = &bePeers->val.l.vals[i];
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
val = tr_bencDictFind( peer, "ip" );
|
|
|
|
if( !val || val->type!=TYPE_STR || tr_netResolve(val->val.s.s, &addr) )
|
|
|
|
continue;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
memcpy( walk, &addr, 4 );
|
|
|
|
walk += 4;
|
2007-10-11 14:56:50 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
val = tr_bencDictFind( peer, "port" );
|
|
|
|
if( !val || val->type!=TYPE_INT || val->val.i<0 || val->val.i>0xffff )
|
|
|
|
continue;
|
2007-10-11 14:56:50 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
port = htons( val->val.i );
|
|
|
|
memcpy( walk, &port, 2 );
|
|
|
|
walk += 2;
|
|
|
|
}
|
2007-10-11 14:56:50 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
*setmePeerCount = peerCount;
|
|
|
|
return compact;
|
2007-10-11 14:56:50 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
static void
|
2007-11-29 00:43:58 +00:00
|
|
|
onTrackerResponse( struct evhttp_request * req, void * torrent_hash )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
const char * warning;
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_tracker * t;
|
|
|
|
int responseCode;
|
|
|
|
|
|
|
|
t = findTrackerFromHash( torrent_hash );
|
|
|
|
tr_free( torrent_hash );
|
|
|
|
if( t == NULL ) /* tracker has been closed */
|
|
|
|
return;
|
|
|
|
|
|
|
|
dbgmsg( t, "got response from tracker: \"%s\"",
|
|
|
|
( req && req->response_code_line ) ? req->response_code_line
|
|
|
|
: "(null)" );
|
|
|
|
|
|
|
|
tr_inf( "Torrent \"%s\" tracker response: %s",
|
|
|
|
t->name,
|
|
|
|
( req ? req->response_code_line : "(null)") );
|
|
|
|
|
|
|
|
if( req && ( req->response_code == HTTP_OK ) )
|
|
|
|
{
|
|
|
|
benc_val_t benc;
|
|
|
|
const int bencLoaded = !parseBencResponse( req, &benc );
|
|
|
|
|
|
|
|
publishErrorClear( t );
|
|
|
|
|
|
|
|
if( bencLoaded && benc.type==TYPE_DICT )
|
|
|
|
{
|
|
|
|
benc_val_t * tmp;
|
|
|
|
|
|
|
|
if(( tmp = tr_bencDictFind( &benc, "failure reason" ))) {
|
|
|
|
dbgmsg( t, "got failure message [%s]", tmp->val.s.s );
|
|
|
|
publishErrorMessage( t, tmp->val.s.s );
|
|
|
|
}
|
|
|
|
|
|
|
|
if(( tmp = tr_bencDictFind( &benc, "warning message" ))) {
|
|
|
|
dbgmsg( t, "got warning message [%s]", tmp->val.s.s );
|
|
|
|
publishWarning( t, tmp->val.s.s );
|
|
|
|
}
|
|
|
|
|
|
|
|
if(( tmp = tr_bencDictFind( &benc, "interval" ))) {
|
|
|
|
dbgmsg( t, "setting interval to %d", tmp->val.i );
|
|
|
|
t->announceIntervalSec = tmp->val.i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(( tmp = tr_bencDictFind( &benc, "min interval" ))) {
|
|
|
|
dbgmsg( t, "setting min interval to %d", tmp->val.i );
|
|
|
|
t->announceMinIntervalSec = tmp->val.i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(( tmp = tr_bencDictFind( &benc, "tracker id" )))
|
|
|
|
t->trackerID = tr_strndup( tmp->val.s.s, tmp->val.s.i );
|
|
|
|
|
|
|
|
if(( tmp = tr_bencDictFind( &benc, "complete" )))
|
|
|
|
t->seederCount = tmp->val.i;
|
|
|
|
|
|
|
|
if(( tmp = tr_bencDictFind( &benc, "incomplete" )))
|
|
|
|
t->leecherCount = tmp->val.i;
|
|
|
|
|
|
|
|
if(( tmp = tr_bencDictFind( &benc, "peers" )))
|
|
|
|
{
|
|
|
|
int peerCount = 0;
|
|
|
|
uint8_t * peerCompact = NULL;
|
|
|
|
|
|
|
|
if( tmp->type == TYPE_LIST ) /* original protocol */
|
|
|
|
{
|
|
|
|
if( tmp->val.l.count > 0 )
|
|
|
|
peerCompact = parseOldPeers( tmp, &peerCount );
|
|
|
|
}
|
|
|
|
else if( tmp->type == TYPE_STR ) /* "compact" extension */
|
|
|
|
{
|
|
|
|
if( tmp->val.s.i >= 6 )
|
|
|
|
{
|
|
|
|
peerCount = tmp->val.s.i / 6;
|
|
|
|
peerCompact = tr_new( uint8_t, tmp->val.s.i );
|
|
|
|
memcpy( peerCompact, tmp->val.s.s, tmp->val.s.i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
publishNewPeers( t, peerCount, peerCompact );
|
|
|
|
tr_free( peerCompact );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bencLoaded )
|
|
|
|
tr_bencFree( &benc );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (( warning = updateAddresses( t, req ) )) {
|
|
|
|
publishWarning( t, warning );
|
|
|
|
tr_err( warning );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
***
|
|
|
|
**/
|
|
|
|
|
|
|
|
responseCode = req ? req->response_code : 503;
|
|
|
|
|
|
|
|
if( 200<=responseCode && responseCode<=299 )
|
|
|
|
{
|
|
|
|
dbgmsg( t, "request succeeded. reannouncing in %d seconds",
|
|
|
|
t->announceIntervalSec );
|
|
|
|
t->reannounceAt = time(NULL) + t->announceIntervalSec;
|
|
|
|
t->manualAnnounceAllowedAt = time(NULL) + t->announceMinIntervalSec;
|
|
|
|
}
|
|
|
|
else if( 300<=responseCode && responseCode<=399 )
|
|
|
|
{
|
|
|
|
dbgmsg( t, "got a redirect; retrying immediately" );
|
|
|
|
|
|
|
|
/* it's a redirect... updateAddresses() has already
|
|
|
|
* parsed the redirect, all that's left is to retry */
|
|
|
|
t->reannounceAt = time(NULL);
|
|
|
|
t->manualAnnounceAllowedAt = time(NULL) + t->announceMinIntervalSec;
|
|
|
|
}
|
|
|
|
else if( 400<=responseCode && responseCode<=499 )
|
|
|
|
{
|
|
|
|
dbgmsg( t, "got a 4xx error." );
|
|
|
|
|
|
|
|
/* The request could not be understood by the server due to
|
|
|
|
* malformed syntax. The client SHOULD NOT repeat the
|
|
|
|
* request without modifications. */
|
|
|
|
if( req && req->response_code_line )
|
|
|
|
publishErrorMessage( t, req->response_code_line );
|
|
|
|
t->manualAnnounceAllowedAt = ~(time_t)0;
|
|
|
|
t->reannounceAt = 0;
|
|
|
|
}
|
|
|
|
else if( 500<=responseCode && responseCode<=599 )
|
|
|
|
{
|
|
|
|
dbgmsg( t, "Got a 5xx error... retrying in 15 seconds." );
|
|
|
|
|
|
|
|
/* Response status codes beginning with the digit "5" indicate
|
|
|
|
* cases in which the server is aware that it has erred or is
|
|
|
|
* incapable of performing the request. So we pause a bit and
|
|
|
|
* try again. */
|
|
|
|
if( req && req->response_code_line )
|
|
|
|
publishWarning( t, req->response_code_line );
|
|
|
|
t->manualAnnounceAllowedAt = ~(time_t)0;
|
|
|
|
t->reannounceAt = time(NULL) + 15;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dbgmsg( t, "Invalid response from tracker... retrying in 60 seconds." );
|
|
|
|
|
|
|
|
/* WTF did we get?? */
|
|
|
|
if( req && req->response_code_line )
|
|
|
|
publishErrorMessage( t, req->response_code_line );
|
|
|
|
t->manualAnnounceAllowedAt = ~(time_t)0;
|
|
|
|
t->reannounceAt = time(NULL) + 60;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
onScrapeResponse( struct evhttp_request * req, void * vhash )
|
|
|
|
{
|
|
|
|
const char * warning;
|
|
|
|
time_t nextScrapeSec = 60;
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_tracker * t;
|
2007-06-26 18:45:03 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
t = findTrackerFromHash( vhash );
|
|
|
|
tr_free( vhash );
|
|
|
|
if( t == NULL ) /* tracker's been closed... */
|
2007-10-08 19:09:20 +00:00
|
|
|
return;
|
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_inf( "Got scrape response for '%s': %s",
|
|
|
|
t->name,
|
|
|
|
( ( req && req->response_code_line ) ? req->response_code_line
|
|
|
|
: "(null)") );
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
if( req && ( req->response_code == HTTP_OK ) )
|
2007-01-20 05:07:00 +00:00
|
|
|
{
|
2007-08-16 20:00:06 +00:00
|
|
|
benc_val_t benc, *files;
|
|
|
|
const int bencLoaded = !parseBencResponse( req, &benc );
|
|
|
|
|
|
|
|
if( bencLoaded
|
|
|
|
&& (( files = tr_bencDictFind( &benc, "files" ) ))
|
|
|
|
&& ( files->type == TYPE_DICT ) )
|
2007-01-20 05:07:00 +00:00
|
|
|
{
|
2007-08-16 20:00:06 +00:00
|
|
|
int i;
|
|
|
|
for( i=0; i<files->val.l.count; i+=2 )
|
|
|
|
{
|
|
|
|
const uint8_t* hash =
|
2007-10-17 18:59:58 +00:00
|
|
|
(const uint8_t*) files->val.l.vals[i].val.s.s;
|
2007-08-16 20:00:06 +00:00
|
|
|
benc_val_t *tmp, *flags;
|
|
|
|
benc_val_t *tordict = &files->val.l.vals[i+1];
|
2007-10-17 18:59:58 +00:00
|
|
|
if( memcmp( t->hash, hash, SHA_DIGEST_LENGTH ) )
|
2007-08-16 20:00:06 +00:00
|
|
|
continue;
|
2007-01-20 05:07:00 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
publishErrorClear( t );
|
2007-09-25 18:39:58 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
if(( tmp = tr_bencDictFind( tordict, "complete" )))
|
2007-10-17 18:59:58 +00:00
|
|
|
t->seederCount = tmp->val.i;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
if(( tmp = tr_bencDictFind( tordict, "incomplete" )))
|
2007-10-17 18:59:58 +00:00
|
|
|
t->leecherCount = tmp->val.i;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
if(( tmp = tr_bencDictFind( tordict, "downloaded" )))
|
2007-10-17 18:59:58 +00:00
|
|
|
t->timesDownloaded = tmp->val.i;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
if(( flags = tr_bencDictFind( tordict, "flags" )))
|
|
|
|
if(( tmp = tr_bencDictFind( flags, "min_request_interval")))
|
2007-10-17 01:17:30 +00:00
|
|
|
t->scrapeIntervalSec = tmp->val.i;
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-08-20 02:29:36 +00:00
|
|
|
tr_dbg( "Torrent '%s' scrape successful."
|
|
|
|
" Rescraping in %d seconds",
|
2007-10-17 18:59:58 +00:00
|
|
|
t->name, t->scrapeIntervalSec );
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
nextScrapeSec = t->scrapeIntervalSec;
|
2007-08-16 20:00:06 +00:00
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
if( bencLoaded )
|
|
|
|
tr_bencFree( &benc );
|
2006-10-13 07:42:55 +00:00
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
if (( warning = updateAddresses( t, req ) )) {
|
|
|
|
tr_err( warning );
|
|
|
|
publishWarning( t, warning );
|
2006-10-13 07:42:55 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
t->scrapeAt = time(NULL) + nextScrapeSec;
|
2006-12-02 01:46:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
2007-10-17 18:59:58 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
struct tr_tracker_request
|
|
|
|
{
|
|
|
|
int port;
|
|
|
|
int timeout;
|
|
|
|
char * address;
|
|
|
|
char * uri;
|
|
|
|
struct evhttp_request * req;
|
|
|
|
};
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
2007-11-29 02:31:21 +00:00
|
|
|
freeRequest( struct tr_tracker_request * req )
|
2007-11-29 00:43:58 +00:00
|
|
|
{
|
2007-11-29 02:31:21 +00:00
|
|
|
tr_free( req->address );
|
|
|
|
tr_free( req->uri );
|
|
|
|
tr_free( req );
|
2007-08-16 20:00:06 +00:00
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
addCommonHeaders( const tr_tracker * t,
|
|
|
|
struct evhttp_request * req )
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
const tr_tracker_info * address = getCurrentAddress( t );
|
|
|
|
snprintf( buf, sizeof(buf), "%s:%d", address->address, address->port );
|
|
|
|
evhttp_add_header( req->output_headers, "Host", buf );
|
|
|
|
evhttp_add_header( req->output_headers, "Connection", "close" );
|
|
|
|
evhttp_add_header( req->output_headers, "Content-Length", "0" );
|
|
|
|
evhttp_add_header( req->output_headers, "User-Agent",
|
|
|
|
TR_NAME "/" LONG_VERSION_STRING );
|
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
static char*
|
2007-10-17 18:59:58 +00:00
|
|
|
buildTrackerRequestURI( const tr_tracker * t,
|
2007-10-04 19:58:30 +00:00
|
|
|
const tr_torrent * torrent,
|
|
|
|
const char * eventName )
|
2007-08-16 20:00:06 +00:00
|
|
|
{
|
2007-10-09 04:50:10 +00:00
|
|
|
const int isStopping = !strcmp( eventName, "stopped" );
|
|
|
|
const int numwant = isStopping ? 0 : NUMWANT;
|
2007-10-17 18:59:58 +00:00
|
|
|
struct evbuffer * buf = evbuffer_new( );
|
|
|
|
char * ret;
|
|
|
|
|
2007-10-25 16:52:12 +00:00
|
|
|
char * ann = getCurrentAddress(t)->announce;
|
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
evbuffer_add_printf( buf, "%s"
|
2007-11-06 16:02:50 +00:00
|
|
|
"%cinfo_hash=%s"
|
2007-10-17 18:59:58 +00:00
|
|
|
"&peer_id=%s"
|
|
|
|
"&port=%d"
|
|
|
|
"&uploaded=%"PRIu64
|
|
|
|
"&downloaded=%"PRIu64
|
|
|
|
"&corrupt=%"PRIu64
|
|
|
|
"&left=%"PRIu64
|
|
|
|
"&compact=1"
|
|
|
|
"&numwant=%d"
|
|
|
|
"&key=%s"
|
2007-10-20 20:27:37 +00:00
|
|
|
"&supportcrypto=1"
|
|
|
|
"&requirecrypto=%d"
|
2007-10-17 18:59:58 +00:00
|
|
|
"%s%s"
|
|
|
|
"%s%s",
|
2007-10-25 16:52:12 +00:00
|
|
|
ann,
|
2007-11-06 16:02:50 +00:00
|
|
|
strchr(ann, '?') ? '&' : '?',
|
2007-10-17 18:59:58 +00:00
|
|
|
t->escaped,
|
|
|
|
t->peer_id,
|
|
|
|
tr_sharedGetPublicPort( t->handle->shared ),
|
2007-08-16 20:00:06 +00:00
|
|
|
torrent->uploadedCur,
|
|
|
|
torrent->downloadedCur,
|
2007-08-21 15:17:02 +00:00
|
|
|
torrent->corruptCur,
|
2007-08-16 20:00:06 +00:00
|
|
|
tr_cpLeftUntilComplete( torrent->completion ),
|
|
|
|
numwant,
|
2007-10-17 18:59:58 +00:00
|
|
|
t->key_param,
|
2007-10-20 20:27:37 +00:00
|
|
|
( t->handle->encryptionMode==TR_ENCRYPTION_REQUIRED ? 1 : 0 ),
|
2007-08-16 20:00:06 +00:00
|
|
|
( ( eventName && *eventName ) ? "&event=" : "" ),
|
|
|
|
( ( eventName && *eventName ) ? eventName : "" ),
|
2007-10-17 18:59:58 +00:00
|
|
|
( ( t->trackerID && *t->trackerID ) ? "&trackerid=" : "" ),
|
|
|
|
( ( t->trackerID && *t->trackerID ) ? t->trackerID : "" ) );
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-10-17 18:59:58 +00:00
|
|
|
ret = tr_strdup( (char*) EVBUFFER_DATA( buf ) );
|
|
|
|
evbuffer_free( buf );
|
|
|
|
return ret;
|
2007-08-16 20:00:06 +00:00
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static struct tr_tracker_request*
|
|
|
|
createRequest( tr_handle * handle, const tr_tracker * tracker, int reqtype )
|
2007-08-16 20:00:06 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
static const char* strings[TR_REQ_COUNT] = { "started", "completed", "stopped", "" };
|
|
|
|
const tr_torrent * torrent = tr_torrentFindFromHash( handle, tracker->hash );
|
|
|
|
const tr_tracker_info * address = getCurrentAddress( tracker );
|
|
|
|
const int isStopping = reqtype == TR_REQ_STOPPED;
|
|
|
|
const char * eventName = strings[reqtype];
|
|
|
|
struct tr_tracker_request * req;
|
|
|
|
|
|
|
|
req = tr_new0( struct tr_tracker_request, 1 );
|
|
|
|
req->address = tr_strdup( address->address );
|
|
|
|
req->port = address->port;
|
|
|
|
req->uri = buildTrackerRequestURI( tracker, torrent, eventName );
|
|
|
|
req->timeout = isStopping ? STOP_TIMEOUT_INTERVAL_SEC : TIMEOUT_INTERVAL_SEC;
|
|
|
|
req->req = isStopping
|
|
|
|
? evhttp_request_new( onStoppedResponse, handle )
|
|
|
|
: evhttp_request_new( onTrackerResponse, torrentHashNew(handle, tracker) );
|
|
|
|
addCommonHeaders( tracker, req->req );
|
|
|
|
|
|
|
|
return req;
|
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static struct tr_tracker_request*
|
|
|
|
createScrape( tr_handle * handle, const tr_tracker * tracker )
|
|
|
|
{
|
|
|
|
const tr_tracker_info * a = getCurrentAddress( tracker );
|
|
|
|
struct tr_tracker_request * req;
|
|
|
|
|
|
|
|
req = tr_new0( struct tr_tracker_request, 1 );
|
|
|
|
req->address = tr_strdup( a->address );
|
|
|
|
req->port = a->port;
|
|
|
|
req->timeout = TIMEOUT_INTERVAL_SEC;
|
|
|
|
req->req = evhttp_request_new( onScrapeResponse, torrentHashNew( handle, tracker ) );
|
|
|
|
tr_asprintf( &req->uri, "%s%cinfo_hash=%s", a->scrape, strchr(a->scrape,'?')?'&':'?', tracker->escaped );
|
|
|
|
addCommonHeaders( tracker, req->req );
|
|
|
|
|
|
|
|
return req;
|
|
|
|
}
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
struct tr_tracker_handle
|
|
|
|
{
|
|
|
|
int socketCount;
|
|
|
|
tr_timer * pulseTimer;
|
|
|
|
tr_list * requestQueue;
|
|
|
|
tr_list * scrapeQueue;
|
|
|
|
};
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static int pulse( void * vhandle );
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
ensureGlobalsExist( tr_handle * handle )
|
|
|
|
{
|
|
|
|
if( handle->tracker == NULL )
|
|
|
|
{
|
|
|
|
handle->tracker = tr_new0( struct tr_tracker_handle, 1 );
|
|
|
|
handle->tracker->pulseTimer = tr_timerNew( handle, pulse, handle, PULSE_INTERVAL_SEC*1000 );
|
|
|
|
dbgmsg( NULL, "creating tracker timer" );
|
|
|
|
}
|
|
|
|
}
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-11-29 02:31:21 +00:00
|
|
|
static void
|
|
|
|
freeRequest2( void * req )
|
|
|
|
{
|
|
|
|
freeRequest( req );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tr_trackerShuttingDown( tr_handle * handle )
|
|
|
|
{
|
|
|
|
/* since we're shutting down, we don't need to scrape anymore... */
|
|
|
|
if( handle->tracker )
|
|
|
|
tr_list_free( &handle->tracker->scrapeQueue, freeRequest2 );
|
|
|
|
}
|
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static int
|
|
|
|
maybeFreeGlobals( tr_handle * handle )
|
|
|
|
{
|
|
|
|
int globalsExist = handle->tracker != NULL;
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
if( globalsExist
|
|
|
|
&& ( handle->tracker->socketCount < 1 )
|
|
|
|
&& ( handle->tracker->requestQueue == NULL )
|
|
|
|
&& ( handle->tracker->scrapeQueue == NULL )
|
|
|
|
&& ( handle->torrentList== NULL ) )
|
|
|
|
{
|
|
|
|
dbgmsg( NULL, "freeing tracker timer" );
|
|
|
|
tr_timerFree( &handle->tracker->pulseTimer );
|
|
|
|
tr_free( handle->tracker );
|
|
|
|
handle->tracker = NULL;
|
|
|
|
globalsExist = FALSE;
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
return globalsExist;
|
2007-08-16 20:00:06 +00:00
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
2007-08-20 02:29:36 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static int
|
|
|
|
freeConnection( void * evcon )
|
2007-10-07 16:07:19 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
evhttp_connection_free( evcon );
|
|
|
|
return FALSE;
|
2007-10-07 16:07:19 +00:00
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
static void
|
2007-11-29 00:43:58 +00:00
|
|
|
connectionClosedCB( struct evhttp_connection * evcon, void * vhandle )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_handle * handle = vhandle;
|
2007-10-04 20:31:19 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
assert( handle );
|
|
|
|
assert( handle->tracker );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/* libevent references evcon right after calling this function,
|
|
|
|
so we can't free it yet... defer it to after this call chain
|
|
|
|
has played out */
|
|
|
|
tr_timerNew( handle, freeConnection, evcon, 100 );
|
2007-10-18 03:55:55 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
--handle->tracker->socketCount;
|
|
|
|
dbgmsg( NULL, "decrementing socket count to %d", handle->tracker->socketCount );
|
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static struct evhttp_connection*
|
|
|
|
getConnection( tr_handle * handle, const char * address, int port )
|
|
|
|
{
|
|
|
|
struct evhttp_connection * c = evhttp_connection_new( address, port );
|
|
|
|
evhttp_connection_set_closecb( c, connectionClosedCB, handle );
|
|
|
|
return c;
|
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
invokeRequest( tr_handle * handle, const struct tr_tracker_request * req )
|
|
|
|
{
|
|
|
|
struct evhttp_connection * evcon = getConnection( handle, req->address, req->port );
|
|
|
|
++handle->tracker->socketCount;
|
|
|
|
dbgmsg( NULL, "incrementing socket count to %d, sending '%s' to tracker %s:%d", handle->tracker->socketCount, req->uri, req->address, req->port );
|
|
|
|
evhttp_connection_set_timeout( evcon, req->timeout );
|
|
|
|
evhttp_make_request( evcon, req->req, EVHTTP_REQ_GET, req->uri );
|
|
|
|
}
|
2007-09-25 18:39:58 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
invokeNextInQueue( tr_handle * handle, tr_list ** list )
|
|
|
|
{
|
|
|
|
struct tr_tracker_request * req = tr_list_pop_front( list );
|
|
|
|
invokeRequest( handle, req );
|
2007-11-29 02:31:21 +00:00
|
|
|
freeRequest( req );
|
2007-11-29 00:43:58 +00:00
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static int
|
|
|
|
socketIsAvailable( tr_handle * handle )
|
|
|
|
{
|
|
|
|
return handle->tracker->socketCount < MAX_TRACKER_SOCKETS;
|
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void ensureGlobalsExist( tr_handle * );
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
enqueueRequest( tr_handle * handle, const tr_tracker * tracker, int reqtype )
|
|
|
|
{
|
|
|
|
struct tr_tracker_request * req;
|
|
|
|
ensureGlobalsExist( handle );
|
|
|
|
req = createRequest( handle, tracker, reqtype );
|
|
|
|
tr_list_append( &handle->tracker->requestQueue, req );
|
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
enqueueScrape( tr_handle * handle, const tr_tracker * tracker )
|
|
|
|
{
|
|
|
|
struct tr_tracker_request * req;
|
|
|
|
ensureGlobalsExist( handle );
|
|
|
|
req = createScrape( handle, tracker );
|
|
|
|
tr_list_append( &handle->tracker->scrapeQueue, req );
|
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static int
|
|
|
|
pulse( void * vhandle )
|
|
|
|
{
|
|
|
|
tr_handle * handle = vhandle;
|
|
|
|
struct tr_tracker_handle * th = handle->tracker;
|
|
|
|
tr_torrent * t;
|
|
|
|
const time_t now = time( NULL );
|
|
|
|
|
|
|
|
if( handle->tracker->socketCount || tr_list_size(th->requestQueue) || tr_list_size(th->scrapeQueue) )
|
|
|
|
dbgmsg( NULL, "tracker pulse... %d sockets, %d reqs left, %d scrapes left", handle->tracker->socketCount, tr_list_size(th->requestQueue), tr_list_size(th->scrapeQueue) );
|
|
|
|
|
|
|
|
/* upkeep: queue periodic rescrape / reannounce */
|
|
|
|
for( t=handle->torrentList; t; t=t->next ) {
|
|
|
|
tr_tracker * tracker = t->tracker;
|
|
|
|
if( tracker->scrapeAt && trackerSupportsScrape( tracker ) && ( now >= tracker->scrapeAt ) ) {
|
|
|
|
tracker->scrapeAt = 0;
|
|
|
|
enqueueScrape( handle, tracker );
|
|
|
|
}
|
|
|
|
if( tracker->reannounceAt && tracker->isRunning && ( now >= tracker->reannounceAt ) ) {
|
|
|
|
tracker->reannounceAt = 0;
|
|
|
|
enqueueRequest( handle, tracker, TR_REQ_REANNOUNCE );
|
|
|
|
}
|
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
if( handle->tracker->socketCount || tr_list_size(th->requestQueue) || tr_list_size(th->scrapeQueue) )
|
|
|
|
dbgmsg( NULL, "tracker pulse after upkeep... %d sockets, %d reqs left, %d scrapes left", handle->tracker->socketCount, tr_list_size(th->requestQueue), tr_list_size(th->scrapeQueue) );
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/* look for things to do... process all the requests, then process all the scrapes */
|
|
|
|
while( th->requestQueue && socketIsAvailable( handle ) )
|
|
|
|
invokeNextInQueue( handle, &th->requestQueue );
|
|
|
|
while( th->scrapeQueue && socketIsAvailable( handle ) )
|
|
|
|
invokeNextInQueue( handle, &th->scrapeQueue );
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
if( handle->tracker->socketCount || tr_list_size(th->requestQueue) || tr_list_size(th->scrapeQueue) )
|
|
|
|
dbgmsg( NULL, "tracker pulse done... %d sockets, %d reqs left, %d scrapes left", handle->tracker->socketCount, tr_list_size(th->requestQueue), tr_list_size(th->scrapeQueue) );
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
return maybeFreeGlobals( handle );
|
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/***
|
|
|
|
**** LIFE CYCLE
|
|
|
|
***/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
generateKeyParam( char * msg, int len )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const char * pool = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
|
|
const int poolSize = strlen( pool );
|
|
|
|
for( i=0; i<len; ++i )
|
|
|
|
*msg++ = pool[tr_rand(poolSize)];
|
|
|
|
*msg = '\0';
|
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
escape( char * out, const uint8_t * in, int in_len ) /* rfc2396 */
|
|
|
|
{
|
|
|
|
const uint8_t *end = in + in_len;
|
|
|
|
while( in != end )
|
|
|
|
if( isalnum(*in) )
|
|
|
|
*out++ = (char) *in++;
|
|
|
|
else
|
|
|
|
out += snprintf( out, 4, "%%%02X", (unsigned int)*in++ );
|
|
|
|
*out = '\0';
|
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_tracker *
|
|
|
|
tr_trackerNew( const tr_torrent * torrent )
|
|
|
|
{
|
|
|
|
const tr_info * info = &torrent->info;
|
|
|
|
int i, j, sum, *iwalk;
|
|
|
|
tr_tracker_info * nwalk;
|
|
|
|
tr_tracker * t;
|
2007-10-18 03:55:55 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_dbg( "making a new tracker for \"%s\"", info->primaryAddress );
|
2007-10-18 03:55:55 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
t = tr_new0( tr_tracker, 1 );
|
|
|
|
t->handle = torrent->handle;
|
|
|
|
t->scrapeIntervalSec = DEFAULT_SCRAPE_INTERVAL_SEC;
|
|
|
|
t->announceIntervalSec = DEFAULT_ANNOUNCE_INTERVAL_SEC;
|
|
|
|
t->announceMinIntervalSec = DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC;
|
|
|
|
generateKeyParam( t->key_param, KEYLEN );
|
2007-10-17 18:59:58 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
t->publisher = tr_publisherNew( );
|
|
|
|
t->timesDownloaded = -1;
|
|
|
|
t->seederCount = -1;
|
|
|
|
t->leecherCount = -1;
|
|
|
|
t->manualAnnounceAllowedAt = ~(time_t)0;
|
|
|
|
t->name = tr_strdup( info->name );
|
|
|
|
memcpy( t->hash, info->hash, SHA_DIGEST_LENGTH );
|
|
|
|
escape( t->escaped, info->hash, SHA_DIGEST_LENGTH );
|
2007-10-18 03:55:55 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
for( sum=i=0; i<info->trackerTiers; ++i )
|
|
|
|
sum += info->trackerList[i].count;
|
|
|
|
t->addresses = nwalk = tr_new0( tr_tracker_info, sum );
|
|
|
|
t->addressIndex = 0;
|
|
|
|
t->addressCount = sum;
|
|
|
|
t->tierFronts = iwalk = tr_new0( int, sum );
|
2007-10-18 03:55:55 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
for( i=0; i<info->trackerTiers; ++i )
|
2007-10-18 03:55:55 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
const int tierFront = nwalk - t->addresses;
|
2007-10-18 03:55:55 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
for( j=0; j<info->trackerList[i].count; ++j )
|
|
|
|
{
|
|
|
|
const tr_tracker_info * src = &info->trackerList[i].list[j];
|
|
|
|
nwalk->address = tr_strdup( src->address );
|
|
|
|
nwalk->port = src->port;
|
|
|
|
nwalk->announce = tr_strdup( src->announce );
|
|
|
|
nwalk->scrape = tr_strdup( src->scrape );
|
|
|
|
++nwalk;
|
|
|
|
|
|
|
|
*iwalk++ = tierFront;
|
|
|
|
}
|
2006-12-02 01:46:54 +00:00
|
|
|
}
|
2007-11-29 00:43:58 +00:00
|
|
|
|
|
|
|
assert( nwalk - t->addresses == sum );
|
|
|
|
assert( iwalk - t->tierFronts == sum );
|
|
|
|
|
|
|
|
if( trackerSupportsScrape( t ) )
|
|
|
|
enqueueScrape( t->handle, t );
|
|
|
|
|
|
|
|
return t;
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
static void
|
|
|
|
onTrackerFreeNow( void * vt )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
int i;
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_tracker * t = vt;
|
2007-10-04 19:58:30 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_publisherFree( &t->publisher );
|
|
|
|
tr_free( t->name );
|
|
|
|
tr_free( t->trackerID );
|
|
|
|
tr_free( t->lastRequest );
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/* addresses... */
|
|
|
|
for( i=0; i<t->addressCount; ++i )
|
|
|
|
tr_trackerInfoClear( &t->addresses[i] );
|
|
|
|
tr_free( t->addresses );
|
|
|
|
tr_free( t->tierFronts );
|
2007-10-18 03:55:55 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
/* redirect... */
|
|
|
|
if( t->redirect ) {
|
|
|
|
tr_trackerInfoClear( t->redirect );
|
|
|
|
tr_free( t->redirect );
|
2007-08-17 03:03:28 +00:00
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_free( t );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 00:43:58 +00:00
|
|
|
void
|
|
|
|
tr_trackerFree( tr_tracker * t )
|
2006-07-16 19:39:23 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
tr_runInEventThread( t->handle, onTrackerFreeNow, t );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-10-18 03:55:55 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
/***
|
|
|
|
**** PUBLIC
|
|
|
|
***/
|
|
|
|
|
|
|
|
tr_publisher_tag
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerSubscribe( tr_tracker * t,
|
2007-08-16 20:00:06 +00:00
|
|
|
tr_delivery_func func,
|
|
|
|
void * user_data )
|
2006-12-02 01:46:54 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
return tr_publisherSubscribe( t->publisher, func, user_data );
|
2006-12-02 01:46:54 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
void
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerUnsubscribe( tr_tracker * t,
|
2007-08-16 20:00:06 +00:00
|
|
|
tr_publisher_tag tag )
|
2006-12-17 16:36:27 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_publisherUnsubscribe( t->publisher, tag );
|
2006-12-17 16:36:27 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
const tr_tracker_info *
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerGetAddress( const tr_tracker * t )
|
2006-12-17 16:36:27 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
return getCurrentAddress( t );
|
2006-12-17 16:36:27 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
int
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerCanManualAnnounce ( const tr_tracker * t)
|
2007-07-12 20:48:13 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
return t->isRunning
|
|
|
|
&& ( time(NULL) >= t->manualAnnounceAllowedAt );
|
2007-07-12 20:48:13 +00:00
|
|
|
}
|
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
void
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerGetCounts( const tr_tracker * t,
|
|
|
|
int * setme_completedCount,
|
|
|
|
int * setme_leecherCount,
|
|
|
|
int * setme_seederCount )
|
2006-12-02 01:46:54 +00:00
|
|
|
{
|
2007-08-20 02:29:36 +00:00
|
|
|
if( setme_completedCount )
|
2007-10-17 18:59:58 +00:00
|
|
|
*setme_completedCount = t->timesDownloaded;
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-08-20 02:29:36 +00:00
|
|
|
if( setme_leecherCount )
|
2007-10-17 18:59:58 +00:00
|
|
|
*setme_leecherCount = t->leecherCount;
|
2006-12-02 01:46:54 +00:00
|
|
|
|
2007-08-20 02:29:36 +00:00
|
|
|
if( setme_seederCount )
|
2007-10-17 18:59:58 +00:00
|
|
|
*setme_seederCount = t->seederCount;
|
2006-12-02 01:46:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-23 03:01:13 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
void
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerStart( tr_tracker * t )
|
2006-12-02 01:46:54 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_peerIdNew( t->peer_id, sizeof(t->peer_id) );
|
2007-11-29 00:43:58 +00:00
|
|
|
if( t->isRunning == 0 ) {
|
2007-10-17 18:59:58 +00:00
|
|
|
t->isRunning = 1;
|
2007-11-29 00:43:58 +00:00
|
|
|
enqueueRequest( t->handle, t, TR_REQ_STARTED );
|
2007-10-04 19:58:30 +00:00
|
|
|
}
|
2006-12-02 01:46:54 +00:00
|
|
|
}
|
2007-01-27 21:17:10 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
void
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerReannounce( tr_tracker * t )
|
2007-01-27 21:17:10 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
enqueueRequest( t->handle, t, TR_REQ_REANNOUNCE );
|
2007-01-27 21:17:10 +00:00
|
|
|
}
|
2007-03-30 00:12:39 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
void
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerCompleted( tr_tracker * t )
|
2007-03-30 00:12:39 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
enqueueRequest( t->handle, t, TR_REQ_COMPLETED );
|
2007-08-16 20:00:06 +00:00
|
|
|
}
|
2007-03-30 00:12:39 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
void
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerStop( tr_tracker * t )
|
2007-08-16 20:00:06 +00:00
|
|
|
{
|
2007-11-29 00:43:58 +00:00
|
|
|
if( t->isRunning ) {
|
2007-10-17 18:59:58 +00:00
|
|
|
t->isRunning = 0;
|
2007-11-29 00:43:58 +00:00
|
|
|
enqueueRequest( t->handle, t, TR_REQ_STOPPED );
|
2007-10-04 19:58:30 +00:00
|
|
|
}
|
2007-08-16 20:00:06 +00:00
|
|
|
}
|
2007-03-30 00:12:39 +00:00
|
|
|
|
2007-08-16 20:00:06 +00:00
|
|
|
void
|
2007-10-17 18:59:58 +00:00
|
|
|
tr_trackerChangeMyPort( tr_tracker * t )
|
2007-08-16 20:00:06 +00:00
|
|
|
{
|
2007-10-17 18:59:58 +00:00
|
|
|
if( t->isRunning )
|
|
|
|
tr_trackerReannounce( t );
|
2007-03-30 00:12:39 +00:00
|
|
|
}
|