Mixe for Privacy and Anonymity in the Internet
CATempIPBlockList.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2000, The JAP-Team
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6 
7  - Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation and/or
12  other materials provided with the distribution.
13 
14  - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
15  may be used to endorse or promote products derived from this software without specific
16  prior written permission.
17 
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
20 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
27 */
28 
29 #ifndef CATEMPIPBLOCKLIST_HPP
30 #define CATEMPIPBLOCKLIST_HPP
31 
32 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_FIRST_MIX
33 
34 #include "CAThread.hpp"
35 #include "CAMutex.hpp"
36 
38  {
41 
45  UINT8 ip[2];
46  };
47 
50 
62 {
63  public:
64  CATempIPBlockList(UINT64 validTimeMillis);
65 
67 
74  SINT32 insertIP(const UINT8 ip[4]);
75 
82  SINT32 checkIP(const UINT8 ip[4]);
83 
88  void setValidTimeMillis(UINT64 millis);
89 
91  {
92  return m_iEntries;
93  }
94 
95  private:
97  volatile bool m_bRunCleanupThread;
98 
101 
103  static THREAD_RETURN cleanupThreadMainLoop(void *param);
104 
107 
110 
113 
115 };
116 
117 #endif //ONLY_LOCAL_PROXY
118 #endif
struct _tempipblocklist_t * PTEMPIPBLOCKLIST
#define THREAD_RETURN
Definition: StdAfx.h:540
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
The purpose of this class is storing the IPs of JAP users who tried to hack/attack the payment system...
UINT64 m_validTimeMillis
the time that each blocked IP should stay in the List
CAMutex * m_pMutex
Used for locking the datastructure to make it threadsafe.
void setValidTimeMillis(UINT64 millis)
set the time (in Milliseconds) that each blocked IP should stay valid in the list
CAThread * m_pCleanupThread
this thread cleans up the hashtable and removes old entries
PTEMPIPBLOCKLIST * m_hashTable
the buffer where the entries are stored
SINT32 insertIP(const UINT8 ip[4])
inserts an IP into the blocklist
volatile bool m_bRunCleanupThread
as long as true the clenaupthread does his job.
CATempIPBlockList(UINT64 validTimeMillis)
static THREAD_RETURN cleanupThreadMainLoop(void *param)
the cleanup thread main loop
SINT32 checkIP(const UINT8 ip[4])
check whether an IP is blocked
struct _tempipblocklist_t * next
Next element, NULL if element is the last one.
UINT64 validTimeMillis
Entry is valid until getCurrentTimeMillis() > validTimeMillis.
UINT8 ip[2]
First two Bytes of the IP-Address.