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:
parent
e5b04e45d5
commit
a09b43a4b4
3 changed files with 29 additions and 3 deletions
|
@ -39,6 +39,7 @@ static struct tr_ip_range * blocklist = NULL;
|
|||
static size_t blocklistItemCount = 0;
|
||||
static size_t blocklistByteCount = 0;
|
||||
static int blocklistFd = -1;
|
||||
static int isEnabled = FALSE;
|
||||
|
||||
void
|
||||
tr_getBlocklistFilename( char * buf, size_t buflen )
|
||||
|
@ -103,12 +104,27 @@ compareAddressToRange( const void * va, const void * vb )
|
|||
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
|
||||
tr_peerIsBlocked( tr_handle * handle UNUSED, const struct in_addr * addr )
|
||||
{
|
||||
uint32_t needle;
|
||||
const struct tr_ip_range * range;
|
||||
|
||||
if( !isEnabled )
|
||||
return FALSE;
|
||||
|
||||
if( !blocklist ) {
|
||||
loadBlocklist( );
|
||||
if( !blocklist )
|
||||
|
|
|
@ -124,7 +124,8 @@ tr_initFull( const char * tag,
|
|||
int downloadLimit,
|
||||
int globalPeerLimit,
|
||||
int messageLevel,
|
||||
int isMessageQueueingEnabled )
|
||||
int isMessageQueueingEnabled,
|
||||
int isBlocklistEnabled )
|
||||
{
|
||||
tr_handle * h;
|
||||
char buf[128];
|
||||
|
@ -177,6 +178,8 @@ tr_initFull( const char * tag,
|
|||
TR_NAME, LONG_VERSION_STRING );
|
||||
tr_inf( "%s", buf );
|
||||
|
||||
tr_blocklistSetEnabled( h, isBlocklistEnabled );
|
||||
|
||||
tr_statsInit( h );
|
||||
|
||||
return h;
|
||||
|
@ -195,7 +198,8 @@ tr_handle * tr_init( const char * tag )
|
|||
-1, /* download speed limit */
|
||||
200, /* globalPeerLimit */
|
||||
TR_MSG_INF, /* message level */
|
||||
FALSE ); /* is message queueing enabled? */
|
||||
FALSE, /* is message queueing enabled? */
|
||||
FALSE ); /* is the blocklist enabled? */
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
|
@ -87,7 +87,8 @@ tr_handle * tr_initFull( const char * tag,
|
|||
int downloadLimit,
|
||||
int globalPeerLimit,
|
||||
int messageLevel,
|
||||
int isMessageQueueingEnabled );
|
||||
int isMessageQueueingEnabled,
|
||||
int isBlocklistEnabled );
|
||||
|
||||
/**
|
||||
* 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_blocklistIsEnabled( const tr_handle * handle );
|
||||
|
||||
void tr_blocklistSetEnabled( tr_handle * handle,
|
||||
int isEnabled );
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
|
|
Loading…
Add table
Reference in a new issue