|
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 // TODO: Sylog for NT!! 00029 00030 #ifndef __CAMSG__ 00031 #define __CAMSG__ 00032 00033 #define MSG_STDOUT 0x01 00034 #define MSG_LOG 0x02 00035 #define MSG_FILE 0x04 00036 #define MSG_COMPRESSED_FILE 0x08 00037 00038 #ifdef _WIN32 00039 #define LOG_ERR 0 00040 #define LOG_CRIT 1 00041 #define LOG_INFO 2 00042 #define LOG_DEBUG 3 00043 #define LOG_WARNING 4 00044 #endif 00045 #define LOG_ENCRYPTED 255 00046 00047 #include "CAMutex.hpp" 00048 #include "CASymCipher.hpp" 00049 00050 struct S_LOGENCCIPHER 00051 { 00052 UINT8 iv[16]; 00053 int iv_off; 00054 AES_KEY oKey; 00055 }; 00056 00057 typedef S_LOGENCCIPHER t_LogEncCipher; 00058 00059 class CAMsg 00060 { 00061 private: 00062 CAMsg(); //Singleton! 00063 static CAMsg* pMsg; 00064 public: 00065 ~CAMsg(); 00066 static SINT32 init() 00067 { 00068 if (pMsg == NULL) 00069 { 00070 pMsg=new CAMsg(); 00071 } 00072 return E_SUCCESS; 00073 } 00074 static SINT32 cleanup() 00075 { 00076 if (pMsg != NULL) 00077 { 00078 pMsg->closeLog(); 00079 } 00080 delete pMsg; 00081 pMsg = NULL; 00082 return E_SUCCESS; 00083 } 00084 static SINT32 setLogOptions(UINT32 options); 00085 static SINT32 setLogLevel(UINT32 a_logLevel); 00086 static SINT32 setMaxLogFileSize(UINT64 size) 00087 { 00088 if(pMsg!=NULL) 00089 { 00090 set64(pMsg->m_maxLogFileSize,size); 00091 return E_SUCCESS; 00092 } 00093 return E_UNKNOWN; 00094 } 00095 00096 static SINT32 printMsg(UINT32 typ,const char* format,...); 00097 //static SINT32 printBytes(UINT32 typ,const char* msg,const UINT8* bytes,UINT32 bytesLen); 00098 00099 #ifndef ONLY_LOCAL_PROXY 00100 static SINT32 openEncryptedLog(); 00101 static SINT32 closeEncryptedLog(); 00102 #endif //ONLY_LOCAL_PROXY 00103 private: 00104 SINT64 m_maxLogFileSize; 00105 UINT32 m_NrOfWrites; 00106 SINT32 openLog(UINT32 type); 00107 SINT32 closeLog(); 00108 SINT32 rotateLog(); 00109 char* createLogFileMessage(UINT32 opt); 00110 char* createLogDirMessage(UINT32 opt); 00111 UINT32 m_uLogType; 00112 UINT32 m_logLevel; 00113 UINT32 m_lastLogFileNumber; 00114 bool m_alreadyOpened; 00115 int m_hFileEncrypted; 00116 int m_hFileInfo; 00117 char *m_strMsgBuff; 00118 char *m_strLogFile; 00119 char *m_strLogDir; 00120 static const char* const m_strMsgTypes[6]; 00121 CAMutex* m_pcsPrint; 00122 #ifdef COMPRESSED_LOGS 00123 gzFile m_gzFileInfo; 00124 #endif 00125 t_LogEncCipher* m_pCipher; 00126 }; 00127 #endif
1.7.6.1