(trunk daemon) #1583: daemon ignores IP address whitelist

This commit is contained in:
Charles Kerr 2008-12-10 19:00:19 +00:00
parent 7403048738
commit 6924741843
1 changed files with 26 additions and 43 deletions

View File

@ -90,25 +90,17 @@ saveState( tr_session * s )
replaceStr( &d, KEY_DOWNLOAD_DIR, tr_sessionGetDownloadDir( s ) );
replaceInt( &d, KEY_PEER_LIMIT, tr_sessionGetPeerLimit( s ) );
replaceInt( &d, KEY_PEER_PORT, tr_sessionGetPeerPort( s ) );
replaceInt( &d, KEY_PORT_FORWARDING,
tr_sessionIsPortForwardingEnabled( s ) );
replaceInt( &d, KEY_PORT_FORWARDING, tr_sessionIsPortForwardingEnabled( s ) );
replaceInt( &d, KEY_PEX_ENABLED, tr_sessionIsPexEnabled( s ) );
replaceStr( &d, KEY_USERNAME, strs[n++] =
tr_sessionGetRPCUsername(
s ) );
replaceStr( &d, KEY_PASSWORD, strs[n++] =
tr_sessionGetRPCPassword(
s ) );
replaceStr( &d, KEY_USERNAME, strs[n++] = tr_sessionGetRPCUsername( s ) );
replaceStr( &d, KEY_PASSWORD, strs[n++] = tr_sessionGetRPCPassword( s ) );
replaceStr( &d, KEY_WHITELIST, strs[n++] = tr_sessionGetRPCWhitelist( s ) );
replaceInt( &d, KEY_RPC_PORT, tr_sessionGetRPCPort( s ) );
replaceInt( &d, KEY_AUTH_REQUIRED, tr_sessionIsRPCPasswordEnabled( s ) );
replaceInt( &d, KEY_DSPEED,
tr_sessionGetSpeedLimit( s, TR_DOWN ) );
replaceInt( &d, KEY_DSPEED_ENABLED,
tr_sessionIsSpeedLimitEnabled( s, TR_DOWN ) );
replaceInt( &d, KEY_DSPEED, tr_sessionGetSpeedLimit( s, TR_DOWN ) );
replaceInt( &d, KEY_DSPEED_ENABLED, tr_sessionIsSpeedLimitEnabled( s, TR_DOWN ) );
replaceInt( &d, KEY_USPEED, tr_sessionGetSpeedLimit( s, TR_UP ) );
replaceInt( &d, KEY_USPEED_ENABLED,
tr_sessionIsSpeedLimitEnabled( s, TR_UP ) );
replaceInt( &d, KEY_USPEED_ENABLED, tr_sessionIsSpeedLimitEnabled( s, TR_UP ) );
replaceInt( &d, KEY_ENCRYPTION, tr_sessionGetEncryption( s ) );
tr_bencSaveJSONFile( myConfigFilename, &d );
@ -180,6 +172,7 @@ session_init( const char * configDir,
if( !tr_bencLoadJSONFile( myConfigFilename, &state ) )
dict = &state;
/***
**** Decide on which values to pass into tr_sessionInitFull().
@ -188,35 +181,25 @@ session_init( const char * configDir,
**** If neither of those can be found, the TR_DEFAULT fields are used .
***/
getConfigStr( dict, KEY_DOWNLOAD_DIR, &downloadDir,
TR_DEFAULT_DOWNLOAD_DIR );
getConfigInt( dict, KEY_PEX_ENABLED, &pexEnabled,
TR_DEFAULT_PEX_ENABLED );
getConfigInt( dict, KEY_PORT_FORWARDING, &fwdEnabled,
TR_DEFAULT_PORT_FORWARDING_ENABLED );
getConfigInt( dict, KEY_PEER_PORT, &peerPort,
TR_DEFAULT_PORT );
getConfigInt( dict, KEY_DSPEED, &downLimit, 100 );
getConfigInt( dict, KEY_DSPEED_ENABLED, &downLimited, FALSE );
getConfigInt( dict, KEY_USPEED, &upLimit, 100 );
getConfigInt( dict, KEY_USPEED_ENABLED, &upLimited, FALSE );
getConfigInt( dict, KEY_LAZY_BITFIELD, &useLazyBitfield,
TR_DEFAULT_LAZY_BITFIELD_ENABLED );
getConfigInt( dict, KEY_PEER_LIMIT, &peers,
TR_DEFAULT_GLOBAL_PEER_LIMIT );
getConfigInt( dict, KEY_BLOCKLIST, &blocklistEnabled,
TR_DEFAULT_BLOCKLIST_ENABLED );
getConfigInt( dict, KEY_RPC_PORT, &rpcPort,
TR_DEFAULT_RPC_PORT );
getConfigInt( dict, KEY_WHITELIST_ENABLED, &whitelistEnabled,
TR_DEFAULT_RPC_WHITELIST_ENABLED );
getConfigStr( dict, KEY_WHITELIST, &whitelist,
TR_DEFAULT_RPC_WHITELIST );
getConfigInt( dict, KEY_AUTH_REQUIRED, &authRequired, FALSE );
getConfigStr( dict, KEY_USERNAME, &username, NULL );
getConfigStr( dict, KEY_PASSWORD, &password, NULL );
getConfigInt( dict, KEY_ENCRYPTION, &encryption,
TR_DEFAULT_ENCRYPTION );
getConfigStr( dict, KEY_DOWNLOAD_DIR, &downloadDir, TR_DEFAULT_DOWNLOAD_DIR );
getConfigInt( dict, KEY_PEX_ENABLED, &pexEnabled, TR_DEFAULT_PEX_ENABLED );
getConfigInt( dict, KEY_PORT_FORWARDING, &fwdEnabled, TR_DEFAULT_PORT_FORWARDING_ENABLED );
getConfigInt( dict, KEY_PEER_PORT, &peerPort, TR_DEFAULT_PORT );
getConfigInt( dict, KEY_DSPEED, &downLimit, 100 );
getConfigInt( dict, KEY_DSPEED_ENABLED, &downLimited, FALSE );
getConfigInt( dict, KEY_USPEED, &upLimit, 100 );
getConfigInt( dict, KEY_USPEED_ENABLED, &upLimited, FALSE );
getConfigInt( dict, KEY_LAZY_BITFIELD, &useLazyBitfield, TR_DEFAULT_LAZY_BITFIELD_ENABLED );
getConfigInt( dict, KEY_PEER_LIMIT, &peers, TR_DEFAULT_GLOBAL_PEER_LIMIT );
getConfigInt( dict, KEY_BLOCKLIST, &blocklistEnabled, TR_DEFAULT_BLOCKLIST_ENABLED );
getConfigInt( dict, KEY_RPC_PORT, &rpcPort, TR_DEFAULT_RPC_PORT );
getConfigStr( dict, KEY_WHITELIST, &whitelist, TR_DEFAULT_RPC_WHITELIST );
getConfigInt( dict, KEY_AUTH_REQUIRED, &authRequired, FALSE );
getConfigStr( dict, KEY_USERNAME, &username, NULL );
getConfigStr( dict, KEY_PASSWORD, &password, NULL );
getConfigInt( dict, KEY_ENCRYPTION, &encryption, TR_DEFAULT_ENCRYPTION );
whitelistEnabled = whitelist && *whitelist;
/***
****