37 #define FILENAME_ENCRYPTEDLOG "/encrypted_messages"
38 #define FILENAME_INFOLOG "/messages"
39 #define FILENAME_INFOLOG_GZ "/messages.gz"
41 #define MAX_MSG_SIZE 8192
45 const char*
const CAMsg::m_strMsgTypes[6]={
", error ] ",
", critical] ",
", info ] ",
", debug ] ",
", special ] ",
", warning ] "};
46 #define STRMSGTYPES_SIZE 12
60 #ifdef COMPRESSED_LOGS
71 #ifndef ONLY_LOCAL_PROXY
84 const char* strLogAtPath =
" at path '%s'";
85 char* strLogFile = NULL;
92 strLogFile =
new char[strlen(strLogAtPath) + strlen(
pMsg->
m_strLogFile) + 1];
96 if (strLogFile == NULL)
98 strLogFile =
new char[1];
106 const char* strLogAtPath =
" Please also check if the directory '%s' exists and create or change it if it does not.";
107 char* strLogFile = NULL;
114 strLogFile =
new char[strlen(strLogAtPath) + strlen(
pMsg->
m_strLogDir) + 1];
118 if (strLogFile == NULL)
120 strLogFile =
new char[1];
121 strLogFile[0] =
'\0';
129 if (a_logLevel == LOG_DEBUG ||
130 a_logLevel == LOG_INFO ||
131 a_logLevel == LOG_WARNING ||
132 a_logLevel == LOG_ERR ||
133 a_logLevel == LOG_CRIT)
164 const char* strLogOpened =
"Message log opened%s%s.\n";
165 const char* strLogErrorMsg =
"Could not open message log%s%s!%s Do you have write permissions?%s\n";
166 const char* strReasonMsg =
" Reason: %s (%u)";
167 char* strLogFile = NULL;
168 char* strLogDir = NULL;
169 char* strReason = NULL;
171 const char* strLogType =
"";
182 strLogType =
" as Syslog";
186 strLogType =
" as Syslog and";
191 strLogType =
" as file";
195 strLogType =
" as compressed file";
203 strBuff =
new char[strlen(strLogOpened) + strlen(strLogType) + strlen(strLogFile) + 1];
204 sprintf(strBuff, strLogOpened, strLogType, strLogFile);
228 strReason =
new char[1];
232 strBuff =
new char[strlen(strLogErrorMsg) + strlen(strLogType) + strlen(strLogFile) + strlen(strReason) + strlen(strLogDir) + 1];
234 sprintf(strBuff, strLogErrorMsg, strLogType, strLogFile, strReason, strLogDir);
266 time_t currtime=time(NULL);
267 strftime(
pMsg->
m_strMsgBuff+1,255,
"%Y/%m/%d-%H:%M:%S",localtime(&currtime));
309 #ifdef HAVE_VSNPRINTF
347 #ifdef COMPRESSED_LOGS
350 if(
pMsg->m_gzFileInfo!=NULL)
367 sprintf(buff,
"%.15s mix AnonMix: ",ctime(&currtime)+4);
392 printf(
"Warning logger is not active!\n");
405 #ifdef COMPRESSED_LOGS
408 if(m_gzFileInfo!=NULL)
409 gzclose(m_gzFileInfo);
431 char logFileSaveName[1026];
432 memset(logFileSaveName, 0, 1026);
450 openlog(
"AnonMix",0,LOG_USER);
453 #ifdef COMPRESSED_LOGS
467 m_gzFileInfo=gzdopen(tmpHandle,
"wb9");
468 if(m_gzFileInfo==NULL)
506 #ifndef ONLY_LOCAL_PROXY
553 oRSA.
encrypt(keyandiv,keyandiv);
#define FILENAME_ENCRYPTEDLOG
#define FILENAME_INFOLOG_GZ
#define MSG_COMPRESSED_FILE
S_LOGENCCIPHER t_LogEncCipher
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
void setZero64(UINT64 &op1)
SINT64 filesize64(int handle)
bool isZero64(UINT64 &op1)
bool isGreater64(UINT64 &op1, UINT64 &op2)
#define GET_NET_ERROR_STR(x)
SINT32 encrypt(const UINT8 *from, UINT8 *to)
Encrypts exactly one block which is stored in from.
SINT32 setPublicKey(const CACertificate *pCert)
Sets the public key which is used for encryption to the contained in the provided certificate.
static SINT32 encode(const UINT8 *in, UINT32 len, UINT8 *out, UINT32 *outlen)
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
CACertificate * getLogEncryptionKey()
Returns a certificate which contains a key which could be used for log encryption.
static CACmdLnOptions * getOptions()
static SINT32 openEncryptedLog()
Open a log, where the logged messages are store encrypted.
static const char *const getLogLevelStr()
SINT32 openLog(UINT32 type)
char * createLogDirMessage(UINT32 opt)
static SINT32 setMaxLogFileSize(UINT64 size)
static SINT32 setLogOptions(UINT32 options)
t_LogEncCipher * m_pCipher
static SINT32 setLogLevel(UINT32 a_logLevel)
UINT32 m_lastLogFileNumber
char * createLogFileMessage(UINT32 opt)
static const char *const m_strMsgTypes[6]
static const char *const ms_arStrLogLevels[5]
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
static SINT32 closeEncryptedLog()