mirror of
git://erdgeist.org/opentracker
synced 2025-02-22 09:01:29 +08:00
The expensive DMEM stats is gone. No need for it, too much potential to DOS.
This commit is contained in:
parent
ad5fa66737
commit
927ac023ce
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
CC?=gcc
|
||||
FEATURES=#-DWANT_TRACKER_SYNC -DWANT_BLACKLISTING -DWANT_CLOSED_TRACKER -DWANT_UTORRENT1600_WORKAROUND #-DWANT_IP_FROM_QUERY_STRING -D_DEBUG_HTTPERROR
|
||||
FEATURES=-DWANT_TRACKER_SYNC #-DWANT_BLACKLISTING -DWANT_CLOSED_TRACKER -DWANT_UTORRENT1600_WORKAROUND #-DWANT_IP_FROM_QUERY_STRING -D_DEBUG_HTTPERROR
|
||||
OPTS_debug=-g -ggdb #-pg # -fprofile-arcs -ftest-coverage
|
||||
OPTS_production=-Os
|
||||
CFLAGS+=-I../libowfat -Wall -pipe -Wextra #-pedantic -ansi
|
||||
|
@ -325,8 +325,6 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
|
||||
mode = STATS_TOP5;
|
||||
else if( !byte_diff(data,4,"fscr"))
|
||||
mode = STATS_FULLSCRAPE;
|
||||
else if( !byte_diff(data,4,"dmem"))
|
||||
mode = STATS_DMEM;
|
||||
else if( !byte_diff(data,4,"tcp4"))
|
||||
mode = STATS_TCP;
|
||||
else if( !byte_diff(data,4,"udp4"))
|
||||
@ -338,16 +336,8 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
|
||||
}
|
||||
}
|
||||
|
||||
switch( mode)
|
||||
{
|
||||
case STATS_DMEM:
|
||||
if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500;
|
||||
return sendmmapdata( s, reply, reply_size );
|
||||
default:
|
||||
// default format for now
|
||||
if( !( reply_size = return_stats_for_tracker( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, mode, 0 ) ) ) HTTPERROR_500;
|
||||
break;
|
||||
}
|
||||
// default format for now
|
||||
if( !( reply_size = return_stats_for_tracker( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, mode, 0 ) ) ) HTTPERROR_500;
|
||||
break;
|
||||
|
||||
/******************************
|
||||
|
41
ot_stats.c
41
ot_stats.c
@ -162,47 +162,6 @@ bailout_cleanup:
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t return_memstat_for_tracker( char **reply ) {
|
||||
size_t torrent_count = 0, j;
|
||||
size_t allocated, replysize;
|
||||
ot_vector *torrents_list;
|
||||
int bucket, k;
|
||||
char *r;
|
||||
|
||||
for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) {
|
||||
torrents_list = mutex_bucket_lock(bucket);
|
||||
torrent_count += torrents_list->size;
|
||||
mutex_bucket_unlock(bucket);
|
||||
}
|
||||
|
||||
allocated = OT_BUCKET_COUNT*32 + (43+OT_POOLS_COUNT*32)*torrent_count;
|
||||
if( !( r = *reply = mmap( NULL, allocated, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0 ) ) ) return 0;
|
||||
|
||||
for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) {
|
||||
torrents_list = mutex_bucket_lock(bucket);
|
||||
r += sprintf( r, "%02X: %08X %08X\n", bucket, (unsigned int)torrents_list->size, (unsigned int)torrents_list->space );
|
||||
mutex_bucket_unlock(bucket);
|
||||
}
|
||||
|
||||
for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) {
|
||||
ot_vector *torrents_list = mutex_bucket_lock(bucket);
|
||||
char hex_out[42];
|
||||
for( j=0; j<torrents_list->size; ++j ) {
|
||||
ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
|
||||
ot_hash *hash =&( ((ot_torrent*)(torrents_list->data))[j] ).hash;
|
||||
r += sprintf( r, "\n%s:\n", to_hex( hex_out, (ot_byte*)hash) );
|
||||
for( k=0; k<OT_POOLS_COUNT; ++k )
|
||||
r += sprintf( r, "\t%05X %05X\n", ((unsigned int)peer_list->peers[k].size), (unsigned int)peer_list->peers[k].space );
|
||||
}
|
||||
mutex_bucket_unlock(bucket);
|
||||
}
|
||||
|
||||
replysize = ( r - *reply );
|
||||
fix_mmapallocation( *reply, allocated, replysize );
|
||||
|
||||
return replysize;
|
||||
}
|
||||
|
||||
static unsigned long events_per_time( unsigned long long events, time_t t ) {
|
||||
return events / ( (unsigned int)t ? (unsigned int)t : 1 );
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#ifndef __OT_STATS_H__
|
||||
#define __OT_STATS_H__
|
||||
|
||||
enum { STATS_CONNS, STATS_PEERS, STATS_TOP5, STATS_DMEM, STATS_TCP, STATS_UDP, STATS_SLASH24S, SYNC_IN, SYNC_OUT, STATS_FULLSCRAPE };
|
||||
enum { STATS_CONNS, STATS_PEERS, STATS_TOP5, STATS_TCP, STATS_UDP, STATS_SLASH24S, STATS_FULLSCRAPE };
|
||||
typedef enum {
|
||||
EVENT_ACCEPT,
|
||||
EVENT_READ,
|
||||
@ -18,8 +18,6 @@ typedef enum {
|
||||
} ot_status_event;
|
||||
|
||||
size_t return_stats_for_tracker( char *reply, int mode, int format );
|
||||
size_t return_memstat_for_tracker( char **reply );
|
||||
|
||||
void stats_issue_event( ot_status_event event, int is_tcp, size_t event_data );
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user