1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-12 23:23:54 +00:00

add tr_blocklistIsEnabled(), tr_blocklistSetEnabled(). add a blocklist flag to tr_initFull().

This commit is contained in:
Charles Kerr 2008-03-29 23:12:34 +00:00
parent e5b04e45d5
commit a09b43a4b4
3 changed files with 29 additions and 3 deletions

View file

@ -39,6 +39,7 @@ static struct tr_ip_range * blocklist = NULL;
static size_t blocklistItemCount = 0; static size_t blocklistItemCount = 0;
static size_t blocklistByteCount = 0; static size_t blocklistByteCount = 0;
static int blocklistFd = -1; static int blocklistFd = -1;
static int isEnabled = FALSE;
void void
tr_getBlocklistFilename( char * buf, size_t buflen ) tr_getBlocklistFilename( char * buf, size_t buflen )
@ -103,12 +104,27 @@ compareAddressToRange( const void * va, const void * vb )
return 0; return 0;
} }
int
tr_blocklistIsEnabled( const tr_handle * handle UNUSED )
{
return isEnabled;
}
void
tr_blocklistSetEnabled( tr_handle * handle UNUSED, int flag )
{
isEnabled = flag ? 1 : 0;
}
int int
tr_peerIsBlocked( tr_handle * handle UNUSED, const struct in_addr * addr ) tr_peerIsBlocked( tr_handle * handle UNUSED, const struct in_addr * addr )
{ {
uint32_t needle; uint32_t needle;
const struct tr_ip_range * range; const struct tr_ip_range * range;
if( !isEnabled )
return FALSE;
if( !blocklist ) { if( !blocklist ) {
loadBlocklist( ); loadBlocklist( );
if( !blocklist ) if( !blocklist )

View file

@ -124,7 +124,8 @@ tr_initFull( const char * tag,
int downloadLimit, int downloadLimit,
int globalPeerLimit, int globalPeerLimit,
int messageLevel, int messageLevel,
int isMessageQueueingEnabled ) int isMessageQueueingEnabled,
int isBlocklistEnabled )
{ {
tr_handle * h; tr_handle * h;
char buf[128]; char buf[128];
@ -177,6 +178,8 @@ tr_initFull( const char * tag,
TR_NAME, LONG_VERSION_STRING ); TR_NAME, LONG_VERSION_STRING );
tr_inf( "%s", buf ); tr_inf( "%s", buf );
tr_blocklistSetEnabled( h, isBlocklistEnabled );
tr_statsInit( h ); tr_statsInit( h );
return h; return h;
@ -195,7 +198,8 @@ tr_handle * tr_init( const char * tag )
-1, /* download speed limit */ -1, /* download speed limit */
200, /* globalPeerLimit */ 200, /* globalPeerLimit */
TR_MSG_INF, /* message level */ TR_MSG_INF, /* message level */
FALSE ); /* is message queueing enabled? */ FALSE, /* is message queueing enabled? */
FALSE ); /* is the blocklist enabled? */
} }
/*** /***

View file

@ -87,7 +87,8 @@ tr_handle * tr_initFull( const char * tag,
int downloadLimit, int downloadLimit,
int globalPeerLimit, int globalPeerLimit,
int messageLevel, int messageLevel,
int isMessageQueueingEnabled ); int isMessageQueueingEnabled,
int isBlocklistEnabled );
/** /**
* Like tr_initFull() but with default values supplied. * Like tr_initFull() but with default values supplied.
@ -311,6 +312,11 @@ void tr_blocklistSet( tr_handle * handle,
int tr_blocklistExists( const tr_handle * handle ); int tr_blocklistExists( const tr_handle * handle );
int tr_blocklistIsEnabled( const tr_handle * handle );
void tr_blocklistSetEnabled( tr_handle * handle,
int isEnabled );
/*********************************************************************** /***********************************************************************