Mixe 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...
#include <CATempIPBlockList.hpp>
Public Member Functions | |
CATempIPBlockList (UINT64 validTimeMillis) | |
~CATempIPBlockList () | |
SINT32 | insertIP (const UINT8 ip[4]) |
inserts an IP into the blocklist More... | |
SINT32 | checkIP (const UINT8 ip[4]) |
check whether an IP is blocked More... | |
void | setValidTimeMillis (UINT64 millis) |
set the time (in Milliseconds) that each blocked IP should stay valid in the list More... | |
UINT32 | count () |
Static Private Member Functions | |
static THREAD_RETURN | cleanupThreadMainLoop (void *param) |
the cleanup thread main loop More... | |
Private Attributes | |
volatile bool | m_bRunCleanupThread |
as long as true the clenaupthread does his job. More... | |
CAThread * | m_pCleanupThread |
this thread cleans up the hashtable and removes old entries More... | |
UINT64 | m_validTimeMillis |
the time that each blocked IP should stay in the List More... | |
PTEMPIPBLOCKLIST * | m_hashTable |
the buffer where the entries are stored More... | |
CAMutex * | m_pMutex |
Used for locking the datastructure to make it threadsafe. More... | |
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
Definition at line 61 of file CATempIPBlockList.hpp.
CATempIPBlockList::CATempIPBlockList | ( | UINT64 | validTimeMillis | ) |
Definition at line 37 of file CATempIPBlockList.cpp.
References cleanupThreadMainLoop(), m_bRunCleanupThread, m_hashTable, m_iEntries, m_pCleanupThread, m_pMutex, m_validTimeMillis, CAThread::setMainLoop(), and CAThread::start().
CATempIPBlockList::~CATempIPBlockList | ( | ) |
Definition at line 56 of file CATempIPBlockList.cpp.
References CAThread::join(), CAMutex::lock(), m_bRunCleanupThread, m_hashTable, m_pCleanupThread, m_pMutex, _tempipblocklist_t::next, CAMsg::printMsg(), and CAMutex::unlock().
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 |
Definition at line 147 of file CATempIPBlockList.cpp.
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.
|
staticprivate |
the cleanup thread main loop
Definition at line 192 of file CATempIPBlockList.cpp.
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().
|
inline |
Definition at line 90 of file CATempIPBlockList.hpp.
References m_iEntries.
inserts an IP into the blocklist
E_SUCCESS | if successful |
E_UNKNOWN | if IP was already in blocklist |
Definition at line 94 of file CATempIPBlockList.cpp.
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().
void CATempIPBlockList::setValidTimeMillis | ( | UINT64 | millis | ) |
set the time (in Milliseconds) that each blocked IP should stay valid in the list
|
private |
as long as true the clenaupthread does his job.
If false the thread will exit.
Definition at line 97 of file CATempIPBlockList.hpp.
Referenced by CATempIPBlockList(), cleanupThreadMainLoop(), and ~CATempIPBlockList().
|
private |
the buffer where the entries are stored
Definition at line 109 of file CATempIPBlockList.hpp.
Referenced by CATempIPBlockList(), checkIP(), cleanupThreadMainLoop(), insertIP(), and ~CATempIPBlockList().
|
private |
Definition at line 114 of file CATempIPBlockList.hpp.
Referenced by CATempIPBlockList(), checkIP(), cleanupThreadMainLoop(), count(), and insertIP().
|
private |
this thread cleans up the hashtable and removes old entries
Definition at line 100 of file CATempIPBlockList.hpp.
Referenced by CATempIPBlockList(), and ~CATempIPBlockList().
|
private |
Used for locking the datastructure to make it threadsafe.
Definition at line 112 of file CATempIPBlockList.hpp.
Referenced by CATempIPBlockList(), checkIP(), cleanupThreadMainLoop(), insertIP(), and ~CATempIPBlockList().
|
private |
the time that each blocked IP should stay in the List
Definition at line 106 of file CATempIPBlockList.hpp.
Referenced by CATempIPBlockList(), and insertIP().