|
Mixe for Privacy and Anonymity in the Internet
|
00001 /* 00002 Copyright (c) 2000, The JAP-Team 00003 All rights reserved. 00004 Redistribution and use in source and binary forms, with or without modification, 00005 are permitted provided that the following conditions are met: 00006 00007 - Redistributions of source code must retain the above copyright notice, 00008 this list of conditions and the following disclaimer. 00009 00010 - Redistributions in binary form must reproduce the above copyright notice, 00011 this list of conditions and the following disclaimer in the documentation and/or 00012 other materials provided with the distribution. 00013 00014 - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors 00015 may be used to endorse or promote products derived from this software without specific 00016 prior written permission. 00017 00018 00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 00020 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00021 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS 00022 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00023 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00024 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00025 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00027 */ 00028 #ifndef __CALASTMIX__ 00029 #define __CALASTMIX__ 00030 #ifndef ONLY_LOCAL_PROXY 00031 #include "CAMix.hpp" 00032 #include "CAMuxSocket.hpp" 00033 #include "CAASymCipher.hpp" 00034 #include "CASocketAddrINet.hpp" 00035 #include "CACacheLoadBalancing.hpp" 00036 //#include "CASignature.hpp" 00037 #include "CAUtil.hpp" 00038 #include "CAQueue.hpp" 00039 #include "CAInfoService.hpp" 00040 #ifdef LOG_CRIME 00041 #include "tre/regex.h" 00042 #endif 00043 #include "CALogPacketStats.hpp" 00044 #ifndef NEW_MIX_TYPE // not TypeB mixes 00045 /* TypeB mixes are using an own implementation */ 00046 #include "CALastMixChannelList.hpp" 00047 #endif 00048 00049 #ifdef REPLAY_DETECTION 00050 #include "CAMixWithReplayDB.hpp" 00051 #endif 00052 00053 THREAD_RETURN lm_loopLog(void*); 00054 THREAD_RETURN lm_loopSendToMix(void* param); 00055 THREAD_RETURN lm_loopReadFromMix(void* pParam); 00056 00057 class CALastMix:public 00058 #ifdef REPLAY_DETECTION 00059 CAMixWithReplayDB 00060 #else 00061 CAMix 00062 #endif 00063 { 00064 public: 00065 CALastMix() 00066 { 00067 m_pMuxIn=NULL; 00068 //m_pSignature=NULL; 00069 m_pMultiSignature=NULL; 00070 m_pRSA=NULL; 00071 m_pInfoService=NULL; 00072 #ifndef NEW_MIX_TYPE // not TypeB mixes 00073 /* TypeB mixes are using an own implementation */ 00074 m_pChannelList=NULL; 00075 #endif 00076 m_pthreadSendToMix=m_pthreadReadFromMix=NULL; 00077 m_pQueueSendToMix=m_pQueueReadFromMix=NULL; 00078 m_pCacheLB=new CACacheLoadBalancing(); 00079 m_pSocksLB=new CACacheLoadBalancing(); 00080 00081 #ifdef LOG_PACKET_STATS 00082 m_pLogPacketStats=NULL; 00083 #endif 00084 #ifdef LOG_CRIME 00085 //OK lets try to use a regular expression for the task instead of a hand crafted parser... 00086 const char* request_line_regexp="[\n\r]*([^ ]+)[ ]+([^ ]+)"; // 00087 m_pregexpRequestLine=new regex_t; 00088 regcomp(m_pregexpRequestLine,request_line_regexp,REG_EXTENDED ); 00089 // Regexp for Domain of URI 00090 const char* uri_regexp="[^:]+[:][/][/]([^:/]+)"; // 00091 m_pregexpDomainOfURI=new regex_t; 00092 regcomp(m_pregexpDomainOfURI,uri_regexp,REG_EXTENDED ); 00093 #endif 00094 } 00095 00096 virtual ~CALastMix() 00097 { 00098 clean(); 00099 delete m_pCacheLB; 00100 m_pCacheLB = NULL; 00101 delete m_pSocksLB; 00102 m_pSocksLB = NULL; 00103 #ifdef LOG_CRIME 00104 regfree(m_pregexpRequestLine); 00105 delete m_pregexpRequestLine; 00106 regfree(m_pregexpDomainOfURI); 00107 delete m_pregexpDomainOfURI; 00108 #endif 00109 } 00110 00111 SINT32 reconfigure(); 00112 tMixType getType() const 00113 { 00114 return CAMix::LAST_MIX; 00115 } 00116 00117 protected: 00118 #ifdef DYNAMIC_MIX 00119 void stopCascade() 00120 { 00121 m_bRestart = true; 00122 } 00123 #endif 00124 virtual SINT32 loop()=0; 00125 SINT32 init(); 00126 virtual SINT32 initOnce(); 00127 SINT32 clean(); 00128 #ifdef NEW_MIX_TYPE // TypeB mixes 00129 virtual void reconfigureMix(); 00130 #endif 00131 00132 // added by ronin <ronin2@web.de> 00133 SINT32 initMixCascadeInfo(DOMElement* ); 00134 00135 // moved to CAMix.hpp 00136 virtual SINT32 processKeyExchange(); 00137 00138 00139 SINT32 setTargets(); 00140 #ifdef LOG_CRIME 00141 bool checkCrime(const UINT8* payLoad,UINT32 payLen,bool bURLCheck); 00142 UINT8 *parseDomainFromPayload(const UINT8 *payloadData, UINT32 payloadDataLength); 00143 #endif 00144 00145 protected: 00146 volatile bool m_bRestart; 00147 CAMuxSocket* m_pMuxIn; 00148 CAQueue* m_pQueueSendToMix; 00149 CAQueue* m_pQueueReadFromMix; 00150 #ifdef LOG_PACKET_TIMES 00151 CALogPacketStats* m_pLogPacketStats; 00152 #endif 00153 CACacheLoadBalancing* m_pCacheLB; 00154 CACacheLoadBalancing* m_pSocksLB; 00155 CAASymCipher* m_pRSA; 00156 CAThread* m_pthreadSendToMix; 00157 CAThread* m_pthreadReadFromMix; 00158 #ifndef NEW_MIX_TYPE // not TypeB mixes 00159 /* TypeB mixes are using an own implementation */ 00160 CALastMixChannelList* m_pChannelList; 00161 #endif 00162 00163 #ifdef LOG_CRIME 00164 regex_t* m_pregexpRequestLine; //Regexp used to find the URI of a request line 00165 regex_t* m_pregexpDomainOfURI; //Regexp to find Domain of URI 00166 regex_t* m_pCrimeRegExpsURL; 00167 UINT32 m_nCrimeRegExpsURL; 00168 regex_t* m_pCrimeRegExpsPayload; 00169 UINT32 m_nCrimeRegExpsPayload; 00170 #endif 00171 00172 protected: 00173 friend THREAD_RETURN lm_loopSendToMix(void* param); 00174 friend THREAD_RETURN lm_loopReadFromMix(void* pParam); 00175 friend THREAD_RETURN lm_loopLog(void*); 00176 volatile bool m_bRunLog; 00177 volatile UINT32 m_logUploadedPackets; 00178 volatile UINT64 m_logUploadedBytes; 00179 volatile UINT32 m_logDownloadedPackets; 00180 volatile UINT64 m_logDownloadedBytes; 00181 }; 00182 00183 #endif 00184 #endif //ONLY_LOCAL_PROXY
1.7.6.1