|
Mixes for Privacy and Anonymity in the Internet
|
The purpose of this class is storing the IPs of JAP users who tried to hack/attack the payment system. More...
Public Member Functions | |
| CATempIPBlockList (UINT64 validTimeMillis) | |
| ~CATempIPBlockList () | |
| SINT32 | insertIP (const UINT8 ip[4]) |
| inserts an IP into the blocklist | |
| SINT32 | checkIP (const UINT8 ip[4]) |
| check whether an IP is blocked | |
| void | setValidTimeMillis (UINT64 millis) |
| set the time (in Milliseconds) that each blocked IP should stay valid in the list | |
| UINT32 | count () |
Static Private Member Functions | |
| static THREAD_RETURN | cleanupThreadMainLoop (void *param) |
| the cleanup thread main loop | |
Private Attributes | |
| volatile bool | m_bRunCleanupThread |
| as long as true the clenaupthread does his job. | |
| CAThread * | m_pCleanupThread |
| this thread cleans up the hashtable and removes old entries | |
| UINT64 | m_validTimeMillis |
| the time that each blocked IP should stay in the List | |
| PTEMPIPBLOCKLIST * | m_hashTable |
| the buffer where the entries are stored | |
| CAMutex * | m_pMutex |
| Used for locking the datastructure to make it threadsafe. | |
| UINT32 | m_iEntries |
The purpose of this class is storing the IPs of JAP users who tried to hack/attack the payment system.
Their IP should stay in this block list for a limited time period (e.g. 10 minutes or so). During this time a JAP cannot connect to the mixcascade from this IP.
The implementation uses Mutex locking and is thus threadsafe
| CATempIPBlockList::CATempIPBlockList | ( | UINT64 | validTimeMillis | ) |
| SINT32 CATempIPBlockList::checkIP | ( | const UINT8 | ip[4] | ) |
check whether an IP is blocked
| 1,if | the IP is blocked |
| 0,if | the IP is not blocked |
| E_SUCCESS,if | the IP is not blocked |
| E_UNKNOWN,if | the IP is blocked |
References E_SUCCESS, E_UNKNOWN, getcurrentTimeMillis(), _tempipblocklist_t::ip, CAMutex::lock(), m_hashTable, m_iEntries, m_pMutex, _tempipblocklist_t::next, CAMutex::unlock(), and _tempipblocklist_t::validTimeMillis.
Referenced by fm_loopAcceptUsers().
| THREAD_RETURN CATempIPBlockList::cleanupThreadMainLoop | ( | void * | param | ) | [static, private] |
the cleanup thread main loop
References BEGIN_STACK, CLEANUP_THREAD_SLEEP_INTERVAL, FINISH_STACK, getcurrentTimeMillis(), INIT_STACK, CAMutex::lock(), m_bRunCleanupThread, m_hashTable, m_iEntries, m_pMutex, _tempipblocklist_t::next, CAMsg::printMsg(), sSleep(), THREAD_RETURN_SUCCESS, CAMutex::unlock(), and _tempipblocklist_t::validTimeMillis.
Referenced by CATempIPBlockList().
References m_iEntries.
Referenced by fm_loopAcceptUsers().
| SINT32 CATempIPBlockList::insertIP | ( | const UINT8 | ip[4] | ) |
inserts an IP into the blocklist
| E_SUCCESS | if successful |
| E_UNKNOWN | if IP was already in blocklist |
References E_SUCCESS, E_UNKNOWN, getcurrentTimeMillis(), _tempipblocklist_t::ip, CAMutex::lock(), m_hashTable, m_iEntries, m_pMutex, m_validTimeMillis, _tempipblocklist_t::next, CAMutex::unlock(), and _tempipblocklist_t::validTimeMillis.
Referenced by CAFirstMix::doUserLogin_internal(), and fm_loopAcceptUsers().
| void CATempIPBlockList::setValidTimeMillis | ( | UINT64 | millis | ) |
set the time (in Milliseconds) that each blocked IP should stay valid in the list
volatile bool CATempIPBlockList::m_bRunCleanupThread [private] |
as long as true the clenaupthread does his job.
If false the thread will exit.
Referenced by CATempIPBlockList(), cleanupThreadMainLoop(), and ~CATempIPBlockList().
PTEMPIPBLOCKLIST* CATempIPBlockList::m_hashTable [private] |
the buffer where the entries are stored
Referenced by CATempIPBlockList(), checkIP(), cleanupThreadMainLoop(), insertIP(), and ~CATempIPBlockList().
UINT32 CATempIPBlockList::m_iEntries [private] |
Referenced by CATempIPBlockList(), checkIP(), cleanupThreadMainLoop(), count(), and insertIP().
CAThread* CATempIPBlockList::m_pCleanupThread [private] |
this thread cleans up the hashtable and removes old entries
Referenced by CATempIPBlockList(), and ~CATempIPBlockList().
CAMutex* CATempIPBlockList::m_pMutex [private] |
Used for locking the datastructure to make it threadsafe.
Referenced by CATempIPBlockList(), checkIP(), cleanupThreadMainLoop(), insertIP(), and ~CATempIPBlockList().
UINT64 CATempIPBlockList::m_validTimeMillis [private] |
the time that each blocked IP should stay in the List
Referenced by CATempIPBlockList(), and insertIP().
1.7.6.1