Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
CATempIPBlockList Class Reference

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 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...
 
CAThreadm_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...
 
PTEMPIPBLOCKLISTm_hashTable
 the buffer where the entries are stored More...
 
CAMutexm_pMutex
 Used for locking the datastructure to make it threadsafe. More...
 
UINT32 m_iEntries
 

Detailed Description

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

Author
Bastian Voigt bavoi.nosp@m.gt@i.nosp@m.nf.fu.nosp@m.-ber.nosp@m.lin.d.nosp@m.e

Constructor & Destructor Documentation

◆ CATempIPBlockList()

CATempIPBlockList::CATempIPBlockList ( UINT64  validTimeMillis)

◆ ~CATempIPBlockList()

CATempIPBlockList::~CATempIPBlockList ( )

Member Function Documentation

◆ checkIP()

SINT32 CATempIPBlockList::checkIP ( const UINT8  ip[4])

check whether an IP is blocked

Return values
1,ifthe IP is blocked
0,ifthe IP is not blocked
E_SUCCESS,ifthe IP is not blocked
E_UNKNOWN,ifthe 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().

◆ cleanupThreadMainLoop()

THREAD_RETURN CATempIPBlockList::cleanupThreadMainLoop ( void *  param)
staticprivate

◆ count()

UINT32 CATempIPBlockList::count ( )

Referenced by fm_loopAcceptUsers().

◆ insertIP()

SINT32 CATempIPBlockList::insertIP ( const UINT8  ip[4])

inserts an IP into the blocklist

Return values
E_SUCCESSif successful
E_UNKNOWNif 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().

◆ setValidTimeMillis()

void CATempIPBlockList::setValidTimeMillis ( UINT64  millis)

set the time (in Milliseconds) that each blocked IP should stay valid in the list

Member Data Documentation

◆ m_bRunCleanupThread

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().

◆ m_hashTable

PTEMPIPBLOCKLIST* CATempIPBlockList::m_hashTable
private

the buffer where the entries are stored

Referenced by CATempIPBlockList(), checkIP(), cleanupThreadMainLoop(), insertIP(), and ~CATempIPBlockList().

◆ m_iEntries

UINT32 CATempIPBlockList::m_iEntries
private

◆ m_pCleanupThread

CAThread* CATempIPBlockList::m_pCleanupThread
private

this thread cleans up the hashtable and removes old entries

Referenced by CATempIPBlockList(), and ~CATempIPBlockList().

◆ m_pMutex

CAMutex* CATempIPBlockList::m_pMutex
private

Used for locking the datastructure to make it threadsafe.

Referenced by CATempIPBlockList(), checkIP(), cleanupThreadMainLoop(), insertIP(), and ~CATempIPBlockList().

◆ m_validTimeMillis

UINT64 CATempIPBlockList::m_validTimeMillis
private

the time that each blocked IP should stay in the List

Referenced by CATempIPBlockList(), and insertIP().