69 m_pChainTable->setDelayParameters(pglobalOptions->getDelayChannelUnlimitTraffic(), pglobalOptions->getDelayChannelBucketGrow(), pglobalOptions->getDelayChannelBucketGrowIntervall());
89 pLogThread->
start(
this);
96 #ifdef LOG_CHAIN_STATISTICS
97 CAMsg::printMsg(LOG_DEBUG,
"Chain log format is: Chain-ID, Chain duration [micros], Upload (bytes), Download (bytes), Packets from user, Packets to user\n");
117 #ifdef LOG_PACKET_TIMES
120 if ((currentMixPacket->
channel > 0) && (currentMixPacket->
channel < 256)) {
133 if (pChannelListEntry == NULL) {
139 #ifdef REPLAY_DETECTION
148 #ifdef LOG_PACKET_TIMES
150 setZero64(currentQueueEntry->timestamp_proccessing_start);
165 channelCipher->
setKey(rsaOutputBuffer);
170 #ifdef LOG_PACKET_TIMES
180 if (currentChain == NULL) {
185 delete channelCipher;
186 channelCipher = NULL;
192 #ifdef LOG_PACKET_TIMES
194 setZero64(pQueueEntry->timestamp_proccessing_start);
206 payloadLength = payloadLength - 1;
236 #ifdef LOG_CHAIN_STATISTICS
237 currentChain->
setSocket(tmpSocket, 1, payloadLength);
259 memcpy(crimeBuff, pChainCell->
firstCell.
data, payloadLength);
265 memset(&oSigCrimeQueueEntry, 0,
sizeof(
tQueueEntry));
270 if (!pglobalOptions->isEncryptedLogEnabled()) {
272 CAMsg::printMsg(log,
"Crime detected -- ID: %u -- Content: \n%s\n",
id, crimeBuff);
285 #ifdef LOG_PACKET_TIMES
287 m_pLogPacketStats->addToTimeingStats(*currentQueueEntry,
CHANNEL_OPEN,
true);
304 if (currentChain != NULL) {
312 if (payloadLength > 0) {
316 #ifdef LOG_CHAIN_STATISTICS
324 #ifdef LOG_PACKET_TIMES
326 m_pLogPacketStats->addToTimeingStats(*currentQueueEntry,
CHANNEL_DATA,
true);
340 CAMsg::printMsg(LOG_DEBUG,
"Unknown chain - cannot continue chain.\n");
346 if (currentChain == NULL) {
351 delete channelCipher;
352 channelCipher = NULL;
358 #ifdef LOG_PACKET_TIMES
360 setZero64(pQueueEntry->timestamp_proccessing_start);
376 CAMsg::printMsg(LOG_INFO,
"Received more than one packet on a channel.\n");
388 SINT32 sendReadySockets = psocketgroupCacheWrite->
select(0);
389 if (sendReadySockets > 0) {
393 while (currentChain != NULL) {
399 while ((currentChain != NULL) && (sendReadySockets > 0)) {
413 #define MAX_MIXIN_SEND_QUEUE_SIZE 1000000
414 psocketgroupCacheRead->
select(0);
420 while (currentChain != NULL) {
421 #ifdef LOG_PACKET_TIMES
426 set64(currentQueueEntry->timestamp_proccessing_start_OP, currentQueueEntry->timestamp_proccessing_start);
431 if ((status == 0) || (status == 2)) {
433 #ifdef LOG_PACKET_TIMES
439 if ((status == 2) || (status == 3)) {
476 #ifdef LOG_PACKET_TIMES
477 CAMsg::printMsg(LOG_CRIT,
"Wait for LoopLogPacketStats to terminate...\n");
478 m_pLogPacketStats->stop();
485 delete currentQueueEntry;
486 currentQueueEntry = NULL;
490 delete psocketgroupCacheWrite;
491 psocketgroupCacheWrite = NULL;
492 delete psocketgroupCacheRead;
493 psocketgroupCacheRead = NULL;
SINT32 getcurrentTimeMicros(UINT64 &u64Time)
Gets the current Systemtime in micros seconds.
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
SINT32 msSleep(UINT32 ms)
Sleeps ms milliseconds.
void setZero64(UINT64 &op1)
void add64(UINT64 &op1, UINT32 op2)
void set64(UINT64 &op1, UINT32 op2)
#define MAX_MIXIN_SEND_QUEUE_SIZE
#define LAST_MIX_TO_PROXY_SEND_TIMEOUT
#define LAST_MIX_TO_PROXY_CONNECT_TIMEOUT
SINT32 decrypt(const UINT8 *from, UINT8 *to)
Decrypts exactly one block which is stored in from.
This class stores Addresses off different Cache-Proxies.
CASocketAddrINet * get()
Gets the 'next' Address according to the Load-Balancing algorithm.
bool isSignaledInSocketGroup(CASocketGroupEpoll *a_socketGroup)
void addToSocketGroup(CASocketGroupEpoll *a_socketGroup)
void signalConnectionError()
void setSocket(CASocket *a_socket)
void addChannel(t_lastMixBChannelListEntry *a_channel, bool a_fastResponse)
void addDataToUpstreamQueue(UINT8 *a_buffer, UINT32 a_size)
UINT32 sendUpstreamData(UINT32 a_maxLength, CASocketGroupEpoll *a_removedSocketGroup)
void signalUnknownChain()
SINT32 processDownstream(CASocketGroupEpoll *a_signalingGroup, MIXPACKET *a_downstreamPacket, UINT32 *a_processedBytes)
Returns: 0, if a packet was created.
CAChain * getFirstEntry()
CAChain * getEntry(UINT8 *a_chainId)
void deleteEntry(UINT8 *a_chainId)
bool proccessMixPacket(const MIXPACKET *pPacket)
SINT32 insert(UINT8 key[16], UINT64 timestamp)
Inserts this key in the replay DB.
t_lastMixBChannelListEntry * add(HCHANNEL a_channelId, CASymChannelCipher *a_channelCipher, CAChain *a_associatedChain)
t_lastMixBChannelListEntry * get(HCHANNEL a_channelId)
volatile UINT32 m_logDownloadedPackets
CAQueue * m_pQueueSendToMix
volatile UINT64 m_logDownloadedBytes
volatile UINT64 m_logUploadedBytes
CAQueue * m_pQueueReadFromMix
CAThread * m_pthreadReadFromMix
CAThread * m_pthreadSendToMix
CACacheLoadBalancing * m_pCacheLB
friend THREAD_RETURN lm_loopLog(void *)
volatile UINT32 m_logUploadedPackets
CACacheLoadBalancing * m_pSocksLB
CAControlChannelDispatcher * m_pMuxInControlChannelDispatcher
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
SINT32 close()
Closes the underlying socket.
SINT32 add(const void *buff, UINT32 size)
Adds data to the Queue.
SINT32 get(UINT8 *pbuff, UINT32 *psize)
Gets up to psize number of bytes from the Queue.
UINT32 getSize()
Returns the size of stored data in byte.
void * getFirstSignaledSocketData()
void * getNextSignaledSocketData()
virtual SINT32 setRecvBuff(UINT32 r)
virtual SINT32 sendTimeOut(const UINT8 *buff, UINT32 len, UINT32 msTimeOut)
Sends some data over the network.
virtual SINT32 setNonBlocking(bool b)
virtual SINT32 setSendBuff(SINT32 r)
Returns < 0 on error, otherwise the new sendbuffersize (which may be less than r)
virtual SINT32 connect(const CASocketAddr &psa)
This class could be used for encryption/decryption of data (streams) with AES using 128bit CBC mode.
SINT32 setKey(const UINT8 *key)
Sets the key for encryption.
SINT32 start(void *param, bool bDaemon=false, bool bSilent=false)
Starts the execution of the main function of this thread.
SINT32 setMainLoop(THREAD_MAIN_TYP fnc)
Sets the main function which will be executed within this thread.
SINT32 join()
Waits for the main function to finish execution.
UINT8 data[MAX_FIRST_UPSTREAM_CHAINCELL_PAYLOAD]
UINT8 chainId[CHAIN_ID_LENGTH]
UINT8 data[MAX_SEQUEL_UPSTREAM_CHAINCELL_PAYLOAD]
t_sequel_upstream_chain_cell sequelCell
t_first_upstream_chain_cell firstCell
#define MIX_PAYLOAD_SOCKS
struct t_queue_entry tQueueEntry
#define MAX_FIRST_UPSTREAM_CHAINCELL_PAYLOAD
#define CHAINFLAG_NEW_CHAIN
#define CHAINFLAG_FAST_RESPONSE
#define MAX_SEQUEL_UPSTREAM_CHAINCELL_PAYLOAD
#define CHAINFLAG_STREAM_CLOSED
#define CHAINFLAG_LENGTH_MASK