29 #if !defined ONLY_LOCAL_PROXY|| defined INCLUDE_LAST_MIX
42 m_u32DelayChannelUnlimitTraffic=DELAY_CHANNEL_TRAFFIC;
43 m_u32DelayChannelBucketGrow=DELAY_BUCKET_GROW;
44 m_u32DelayChannelBucketGrowIntervall=DELAY_BUCKET_GROW_INTERVALL;
47 m_pMutexDelayChannel=
new CAMutex();
48 m_pThreadDelayBucketsLoop=
new CAThread((
UINT8*)
"Delay Buckets Thread");
49 m_bDelayBucketsLoopRun=
true;
50 m_pThreadDelayBucketsLoop->setMainLoop(lml_loopDelayBuckets);
51 m_pThreadDelayBucketsLoop->start(
this);
53 #ifdef DELAY_CHANNELS_LATENCY
64 m_bDelayBucketsLoopRun=
false;
65 m_pThreadDelayBucketsLoop->join();
66 delete m_pThreadDelayBucketsLoop;
67 m_pThreadDelayBucketsLoop = NULL;
68 delete m_pMutexDelayChannel;
69 m_pMutexDelayChannel = NULL;
70 delete []m_pDelayBuckets;
71 m_pDelayBuckets = NULL;
94 #ifdef WITH_INTEGRITY_CHECK
104 #
if defined(DELAY_CHANNELS_LATENCY)
108 ,
bool bIsCrime,
bool bLogPayload, time_t timeChannelOpened
110 #ifdef ANON_DEBUG_MODE
123 #if defined (LOG_CHANNEL)
124 pNewEntry->timeCreated=timecreated;
126 #if defined (DELAY_CHANNELS_LATENCY)
127 pNewEntry->timeLatency=delaytime+m_u32DelayChannelLatency;
130 pNewEntry->trafficInFromUser=trafficInFromUser;
131 pNewEntry->packetsDataInFromUser=1;
132 pNewEntry->packetsDataOutToUser=0;
133 pNewEntry->trafficOutToUser=0;
136 pNewEntry->bIsCrime=bIsCrime;
137 pNewEntry->bLogPayload=bLogPayload;
138 pNewEntry->timeChannelOpened=timeChannelOpened;
140 #ifdef ANON_DEBUG_MODE
141 pNewEntry->bDebug = bDebug;
145 #ifdef DELAY_CHANNELS
146 pNewEntry->delayBucket=m_u32DelayChannelUnlimitTraffic;
149 if(m_pDelayBuckets[i]==NULL)
151 pNewEntry->delayBucketID=i;
155 m_pDelayBuckets[pNewEntry->delayBucketID]=&pNewEntry->delayBucket;
226 #ifdef DELAY_CHANNELS
227 m_pMutexDelayChannel->lock();
228 m_pDelayBuckets[pEntry->delayBucketID]=NULL;
229 m_pMutexDelayChannel->unlock();
232 if (pEntry->bIsCrime)
238 strftime(buff, 255,
"%Y/%m/%d-%H:%M:%S", localtime(&pEntry->timeChannelOpened));
239 CAMsg::printMsg(log,
"Crime channel closed (opened at: %s [unix timestamp: %u]) -- previous mix channel: %u\n", buff,pEntry->timeChannelOpened,pEntry->
channelIn);
258 #if !defined (LOG_CHANNEL)&&!defined(DELAY_CHANNELS_LATENCY)&&!defined(LOG_CRIME)&&!defined(ANON_DEBUG_MODE)
266 oList.
add(c,NULL,NULL,NULL);
269 for(i=0;i < 10000;i++)
278 oList.
add(c,NULL,NULL,NULL);
288 oList.
add(c,NULL,NULL,NULL);
304 #ifdef DELAY_CHANNELS
308 UINT32** pDelayBuckets=pChannelList->m_pDelayBuckets;
309 while(pChannelList->m_bDelayBucketsLoopRun)
311 pChannelList->m_pMutexDelayChannel->lock();
312 UINT32 u32BucketGrow=pChannelList->m_u32DelayChannelBucketGrow;
313 UINT32 u32MaxBucket=u32BucketGrow*10;
316 if(pDelayBuckets[i]!=NULL&&*(pDelayBuckets[i])<u32MaxBucket)
317 *(pDelayBuckets[i])+=u32BucketGrow;
319 pChannelList->m_pMutexDelayChannel->unlock();
320 msSleep(pChannelList->m_u32DelayChannelBucketGrowIntervall);
325 void CALastMixChannelList::reduceDelayBuckets(
UINT32 delayBucketID,
UINT32 amount)
327 m_pMutexDelayChannel->lock();
328 if (*(m_pDelayBuckets[delayBucketID]) < amount)
330 *(m_pDelayBuckets[delayBucketID]) = 0;
334 *(m_pDelayBuckets[delayBucketID]) -= amount;
336 m_pMutexDelayChannel->unlock();
363 void CALastMixChannelList::setDelayParameters(
UINT32 unlimitTraffic,
UINT32 bucketGrow,
UINT32 intervall)
365 m_pMutexDelayChannel->lock();
366 CAMsg::printMsg(LOG_DEBUG,
"CALastMixChannelList - Set new traffic limit per channel- unlimit: %u bucketgrow: %u intervall %u\n",
367 unlimitTraffic,bucketGrow,intervall);
368 m_u32DelayChannelUnlimitTraffic=unlimitTraffic;
369 m_u32DelayChannelBucketGrow=bucketGrow;
370 m_u32DelayChannelBucketGrowIntervall=intervall;
372 if(m_pDelayBuckets[i]!=NULL)
373 *(m_pDelayBuckets[i])=m_u32DelayChannelUnlimitTraffic;
374 m_pMutexDelayChannel->unlock();
378 #ifdef DELAY_CHANNELS_LATENCY
379 void CALastMixChannelList::setDelayLatencyParameters(
UINT32 latency)
381 CAMsg::printMsg(LOG_DEBUG,
"CALastMixChannelList - Set new latency: %u ms\n",latency);
382 m_u32DelayChannelLatency=latency;
struct t_lastmixchannellist lmChannelListEntry
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
SINT32 msSleep(UINT32 ms)
Sleeps ms milliseconds.
#define DELAY_CHANNEL_LATENCY
#define THREAD_RETURN_SUCCESS
SINT32 add(HCHANNEL id, CASocket *pSocket, CASymChannelCipher *pCipher, CAQueue *pQueue)
lmChannelList * m_listSockets
Pointer to the head of a list of all sockets.
lmChannelListEntry * getFirstSocket()
lmChannelListEntry * getNextSocket()
lmChannelList * m_listSocketsNext
Next Element in the enumeration of all sockets.
SINT32 removeChannel(HCHANNEL channelIn)
LP_lmChannelListEntry * m_HashTable
The Hash-Table of all channels.
static CACmdLnOptions * getOptions()
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
This is a simple FIFO-Queue.
This class could be used for encryption/decryption of data (streams) with AES using 128bit GCM mode.
struct t_lastmixchannellist::@4 list_Channels
CASymChannelCipher * pCipher
SINT32 sendmeCounterDownstream
struct t_lastmixchannellist::@5 list_Sockets
SINT32 sendmeCounterUpstream
struct t_lastmixchannellist * next
struct t_lastmixchannellist * prev