Mixes for Privacy and Anonymity in the Internet
|
The purpose of this class is to store a list of IP-Addresses. More...
Public Member Functions | |
CAIPList () | |
TODO: Fix LOG_TRAFFIC output which is not done anymore, as per default no log message are ommited... More... | |
CAIPList (UINT32 allowedConnections) | |
Constructs a empty CAIPList, there allowedConnections insertions are allowed, until an error is returned. More... | |
~CAIPList () | |
Deletes the IPList and frees all used resources. More... | |
SINT32 | insertIP (const UINT8 ip[4]) |
Inserts the IP-Address into the list. More... | |
SINT32 | removeIP (const UINT8 ip[4]) |
Removes the IP-Address from the list. More... | |
Private Attributes | |
UINT32 | m_allowedConnections |
volatile VOLATILE_PIPLIST * | m_HashTable |
CAMutex * | m_pMutex |
The purpose of this class is to store a list of IP-Addresses.
If an IP-Address is inserted more than 'x' times, than an error is returned. The First mix uses this functionalty to do some basic Denial Of Service defense. If someone tries to do connection flooding to the First Mix, only 'x' connections are accepted and the others are droped. The internal organisation is a hash-table with overrun lists. The hashtable has 0x10000 buckets. The last two bytes of an IP-Address are the hash-key.
CAIPList::CAIPList | ( | ) |
TODO: Fix LOG_TRAFFIC output which is not done anymore, as per default no log message are ommited...
Constructs an empty CAIPList. The default number MAX_IP_CONNECTIONS of allowed insertions is used
References getRandom(), m_allowedConnections, m_HashTable, m_pMutex, and MAX_IP_CONNECTIONS.
CAIPList::CAIPList | ( | UINT32 | allowedConnections | ) |
Constructs a empty CAIPList, there allowedConnections insertions are allowed, until an error is returned.
allowedConnections | number of insertions of the same IP-Address, until an error is returned |
References getRandom(), m_allowedConnections, m_HashTable, and m_pMutex.
CAIPList::~CAIPList | ( | ) |
Deletes the IPList and frees all used resources.
References m_HashTable, m_pMutex, and _iplist_t::next.
Inserts the IP-Address into the list.
If the IP-Address is already in the list then the number of insert() called for this IP-Adress is returned. If this number is larger than m_allowedConnections an error is returned. Intern handelt es sich um eine Hashtabelle mit Ueberlaufliste. Die letzten 16 Bit der IP-Adresse bilden dabei den Hashkey. Die Hashtabelle hat 16^2 Eintraege. In den Ueberlauflisten der einzelnen Hasheintraege sind die ersten 16 Bit der IP-Adresse gespeichert.
ip | the IP-Address to insert |
E_UNKNOWN | if an error occured or an IP is inserted more than m_allowedConnections times |
References _iplist_t::count, E_SUCCESS, E_UNKNOWN, _iplist_t::ip, CAMutex::lock(), m_allowedConnections, m_HashTable, m_pMutex, _iplist_t::next, CAMsg::printMsg(), and CAMutex::unlock().
Removes the IP-Address from the list.
ip | IP-Address to remove |
0 | if IP-Address is delete form the list |
References _iplist_t::count, E_SUCCESS, _iplist_t::ip, CAMutex::lock(), m_HashTable, m_pMutex, _iplist_t::next, CAMsg::printMsg(), and CAMutex::unlock().
Referenced by CAFirstMixA::closeConnection(), CAFirstMix::doUserLogin_internal(), and CAFirstMixB::loop().
|
private |
Referenced by CAIPList(), and insertIP().
|
private |
Referenced by CAIPList(), insertIP(), removeIP(), and ~CAIPList().
|
private |
Referenced by CAIPList(), insertIP(), removeIP(), and ~CAIPList().