Mixe for Privacy and Anonymity in the Internet
CALastMix.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 #ifndef __CALASTMIX__
29 #define __CALASTMIX__
30 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_LAST_MIX
31 #include "CAMix.hpp"
32 #include "CAMuxSocket.hpp"
33 #include "CAASymCipher.hpp"
34 #include "CASocketAddrINet.hpp"
35 #include "CACacheLoadBalancing.hpp"
36 //#include "CASignature.hpp"
37 #include "CAUtil.hpp"
38 #include "CAQueue.hpp"
39 #include "CAInfoService.hpp"
40 #ifdef LOG_CRIME
41  #include "tre/tre.h"
42  #include "SquidLogHelper/SquidLogHelper.hpp"
43 #endif
44 #include "CALogPacketStats.hpp"
45 #ifndef NEW_MIX_TYPE // not TypeB mixes
46  /* TypeB mixes are using an own implementation */
47  #include "CALastMixChannelList.hpp"
48 #endif
49 
50 #ifdef REPLAY_DETECTION
51  #include "CAMixWithReplayDB.hpp"
52 #endif
53 
55 THREAD_RETURN lm_loopSendToMix(void* param);
56 THREAD_RETURN lm_loopReadFromMix(void* pParam);
57 
58 class CALastMix:public
59 #ifdef REPLAY_DETECTION
61 #else
62  CAMix
63 #endif
64  {
65  public:
67  {
68  m_pMuxIn=NULL;
69  //m_pSignature=NULL;
70  m_pMultiSignature=NULL;
71  m_pRSA=NULL;
72  m_pInfoService=NULL;
73  #ifndef NEW_MIX_TYPE // not TypeB mixes
74  /* TypeB mixes are using an own implementation */
75  m_pChannelList=NULL;
76  #endif
82 
83  #ifdef LOG_PACKET_STATS
84  m_pLogPacketStats=NULL;
85  #endif
86  #ifdef LOG_CRIME
87  //OK lets try to use a regular expression for the task instead of a hand crafted parser...
88  const char* request_line_regexp="[\n\r]*([^ ]+)[ ]+([^ ]+)"; //
89  m_pregexpRequestLine=new tre_regex_t;
90  tre_regcomp(m_pregexpRequestLine,request_line_regexp,REG_EXTENDED );
91  // Regexp for Domain of URI
92  const char* uri_regexp="[^:]+[:][/][/]([^:/]+)"; //
93  m_pregexpDomainOfURI=new tre_regex_t;
94  tre_regcomp(m_pregexpDomainOfURI,uri_regexp,REG_EXTENDED );
95  m_pSquidLogHelper = NULL;
96  #endif
97  }
98 
99  virtual ~CALastMix()
100  {
101  clean();
102  delete m_pCacheLB;
103  m_pCacheLB = NULL;
104  delete m_pSocksLB;
105  m_pSocksLB = NULL;
106  delete m_pVPNLB;
107  m_pVPNLB = NULL;
108 #ifdef LOG_CRIME
109  tre_regfree(m_pregexpRequestLine);
110  delete m_pregexpRequestLine;
111  tre_regfree(m_pregexpDomainOfURI);
112  delete m_pregexpDomainOfURI;
113 #endif
114  }
115 
118  {
119  return CAMix::LAST_MIX;
120  }
121 
122  protected:
123 #ifdef DYNAMIC_MIX
124  void stopCascade()
125  {
126  m_bRestart = true;
127  }
128 #endif
129  virtual SINT32 loop()=0;
130  SINT32 init();
131  virtual SINT32 initOnce();
132  SINT32 clean();
133  #ifdef NEW_MIX_TYPE // TypeB mixes
134  virtual void reconfigureMix();
135  #endif
136 
137  // added by ronin <ronin2@web.de>
138  SINT32 initMixCascadeInfo(DOMElement* );
139 
140  // moved to CAMix.hpp
141  virtual SINT32 processKeyExchange();
142 
143 
144  SINT32 setTargets();
145 #ifdef LOG_CRIME
146  bool checkCrime(const UINT8* payLoad,UINT32 payLen,bool bURLCheck);
147  UINT8 *parseDomainFromPayload(const UINT8 *payloadData, UINT32 payloadDataLength);
148 #endif
149 
150  protected:
151  volatile bool m_bRestart;
155  #ifdef LOG_PACKET_TIMES
156  CALogPacketStats* m_pLogPacketStats;
157  #endif
164  #ifndef NEW_MIX_TYPE // not TypeB mixes
165  /* TypeB mixes are using an own implementation */
167  #endif
168 
169 #ifdef LOG_CRIME
170  tre_regex_t* m_pregexpRequestLine; //Regexp used to find the URI of a request line
171  tre_regex_t* m_pregexpDomainOfURI; //Regexp to find Domain of URI
172  tre_regex_t* m_pCrimeRegExpsURL;
173  UINT32 m_nCrimeRegExpsURL;
174  tre_regex_t* m_pCrimeRegExpsPayload;
175  UINT32 m_nCrimeRegExpsPayload;
176  CASquidLogHelper* m_pSquidLogHelper;
177  public:
178  void externalCrimeNotifier(UINT8 lastMixToProxyConnectionSrcIP[4],
179  UINT16 lastMixToProxyConnectionSrcPort,
180  UINT8 lastMixToProxyConnectionDstIP[4],
181  UINT16 lastMixToProxyConnectionDstPort, UINT8* pstrExternalLogEntry);
182 
183 #endif
184 
185  protected:
186  friend THREAD_RETURN lm_loopSendToMix(void* param);
187  friend THREAD_RETURN lm_loopReadFromMix(void* pParam);
188  friend THREAD_RETURN lm_loopLog(void*);
189  volatile bool m_bRunLog;
194  };
195 
196 #endif
197 #endif //ONLY_LOCAL_PROXY
THREAD_RETURN lm_loopReadFromMix(void *pParam)
Definition: CALastMix.cpp:731
THREAD_RETURN lm_loopSendToMix(void *param)
How to end this thread: 0.
Definition: CALastMix.cpp:623
THREAD_RETURN lm_loopLog(void *)
Definition: CALastMix.cpp:591
#define THREAD_RETURN
Definition: StdAfx.h:540
unsigned short UINT16
Definition: basetypedefs.h:133
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
This class stores Addresses off different Cache-Proxies.
volatile bool m_bRunLog
Definition: CALastMix.hpp:189
volatile UINT32 m_logDownloadedPackets
Definition: CALastMix.hpp:192
CAQueue * m_pQueueSendToMix
Definition: CALastMix.hpp:153
volatile UINT64 m_logDownloadedBytes
Definition: CALastMix.hpp:193
SINT32 initMixCascadeInfo(DOMElement *)
This will initialize the XML Cascade Info struct XMLFirstMixToInfoService that is sent to the InfoSer...
Definition: CALastMix.cpp:1140
SINT32 setTargets()
Reads the configured proxies from options.
Definition: CALastMix.cpp:971
friend THREAD_RETURN lm_loopReadFromMix(void *pParam)
Definition: CALastMix.cpp:731
volatile UINT64 m_logUploadedBytes
Definition: CALastMix.hpp:191
virtual SINT32 processKeyExchange()
Processes the startup communication with the preceeding mix.
Definition: CALastMix.cpp:236
CACacheLoadBalancing * m_pVPNLB
Definition: CALastMix.hpp:160
CAASymCipher * m_pRSA
Definition: CALastMix.hpp:161
CALastMixChannelList * m_pChannelList
Definition: CALastMix.hpp:166
virtual SINT32 initOnce()
Definition: CALastMix.cpp:56
virtual ~CALastMix()
Definition: CALastMix.hpp:99
friend THREAD_RETURN lm_loopSendToMix(void *param)
How to end this thread: 0.
Definition: CALastMix.cpp:623
tMixType getType() const
Definition: CALastMix.hpp:117
CAQueue * m_pQueueReadFromMix
Definition: CALastMix.hpp:154
CAThread * m_pthreadReadFromMix
Definition: CALastMix.hpp:163
CAThread * m_pthreadSendToMix
Definition: CALastMix.hpp:162
CACacheLoadBalancing * m_pCacheLB
Definition: CALastMix.hpp:158
friend THREAD_RETURN lm_loopLog(void *)
Definition: CALastMix.cpp:591
volatile UINT32 m_logUploadedPackets
Definition: CALastMix.hpp:190
SINT32 reconfigure()
Definition: CALastMix.cpp:560
CAMuxSocket * m_pMuxIn
Definition: CALastMix.hpp:152
volatile bool m_bRestart
Definition: CALastMix.hpp:151
SINT32 clean()
Definition: CALastMix.cpp:1031
SINT32 init()
Definition: CALastMix.cpp:84
virtual SINT32 loop()=0
CACacheLoadBalancing * m_pSocksLB
Definition: CALastMix.hpp:159
Definition: CAMix.hpp:49
CAInfoService * m_pInfoService
Definition: CAMix.hpp:184
CAMultiSignature * m_pMultiSignature
Definition: CAMix.hpp:183
tMixType
Definition: CAMix.hpp:52
@ LAST_MIX
Definition: CAMix.hpp:55
This class (interface) adds the functionality used by last and middle mixes to detecte replays.
This is a simple FIFO-Queue.
Definition: CAQueue.hpp:50