From 16880cee9904fb91e96ea390d10abae5ec1d0ca6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 5 Apr 2008 16:49:26 +0000 Subject: [PATCH] #765, part 1: add backend support for disabling tracker scrapes --- libtransmission/internal.h | 13 +++++++------ libtransmission/tracker.c | 3 ++- libtransmission/transmission.c | 23 ++++++++++++++++++++--- libtransmission/transmission.h | 4 ++++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/libtransmission/internal.h b/libtransmission/internal.h index 89ecefee4..34d46e544 100644 --- a/libtransmission/internal.h +++ b/libtransmission/internal.h @@ -55,6 +55,13 @@ const uint8_t* tr_getPeerId( void ); struct tr_handle { + unsigned int isScrapeEnabled : 1; + unsigned int isPortSet : 1; + unsigned int isPexEnabled : 1; + unsigned int isClosed : 1; + unsigned int useUploadLimit : 1; + unsigned int useDownloadLimit : 1; + tr_encryption_mode encryptionMode; struct tr_event_handle * events; @@ -63,11 +70,7 @@ struct tr_handle tr_torrent * torrentList; char * tag; - unsigned int isPortSet : 1; - unsigned int isPexEnabled : 1; - char useUploadLimit; - char useDownloadLimit; struct tr_ratecontrol * upload; struct tr_ratecontrol * download; @@ -80,8 +83,6 @@ struct tr_handle tr_handle_status stats[2]; int statCur; - uint8_t isClosed; - struct tr_stats_handle * sessionStats; struct tr_tracker_handle * tracker; }; diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index 7cc578950..29dc74b00 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -178,7 +178,8 @@ trackerSupportsScrape( const tr_tracker * t ) { const tr_tracker_info * info = getCurrentAddress( t ); - return ( info != NULL ) + return ( t->handle->isScrapeEnabled ) + && ( info != NULL ) && ( info->scrape != NULL ) && ( info->scrape[0] != '\0' ); } diff --git a/libtransmission/transmission.c b/libtransmission/transmission.c index dbddcb134..e989136a5 100644 --- a/libtransmission/transmission.c +++ b/libtransmission/transmission.c @@ -305,9 +305,10 @@ tr_setUseGlobalSpeedLimit( tr_handle * h, int up_or_down, int use_flag ) { - char * ch = up_or_down==TR_UP ? &h->useUploadLimit - : &h->useDownloadLimit; - *ch = use_flag; + if( up_or_down == TR_UP ) + h->useUploadLimit = use_flag ? 1 : 0; + else + h->useDownloadLimit = use_flag ? 1 : 0; } void @@ -530,3 +531,19 @@ tr_blocklistHasAddress( tr_handle * handle, const struct in_addr * addr ) { return _tr_blocklistHasAddress( handle->blocklist, addr ); } + +/*** +**** +***/ + +void +tr_setScrapeEnabled( tr_handle * handle, int isEnabled ) +{ + handle->isScrapeEnabled = isEnabled ? 1 : 0; +} + +int +tr_isScrapeEnabled( const tr_handle * handle ) +{ + return handle->isScrapeEnabled; +} diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 7cbb090e5..f4293e862 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -603,6 +603,10 @@ void tr_manualUpdate( tr_torrent * ); int tr_torrentCanManualUpdate( const tr_torrent * ); +void tr_setScrapeEnabled( tr_handle * , int isEnabled ); + +int tr_isScrapeEnabled( const tr_handle * ); + /*********************************************************************** * tr_torrentStat *********************************************************************** -- 2.40.0