summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index f4c61d3..54f236f 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -24,7 +24,6 @@
24 24
25/* GLOBAL VARIABLES */ 25/* GLOBAL VARIABLES */
26static ot_vector all_torrents[256]; 26static ot_vector all_torrents[256];
27
28#ifdef WANT_CLOSED_TRACKER 27#ifdef WANT_CLOSED_TRACKER
29int g_closedtracker = 1; 28int g_closedtracker = 1;
30static ot_torrent* const OT_TORRENT_NOT_ON_WHITELIST = (ot_torrent*)1; 29static ot_torrent* const OT_TORRENT_NOT_ON_WHITELIST = (ot_torrent*)1;
@@ -329,6 +328,37 @@ size_t return_fullscrape_for_tracker( char **reply ) {
329 return r - *reply; 328 return r - *reply;
330} 329}
331 330
331size_t return_memstat_for_tracker( char **reply ) {
332 size_t torrent_count = 0, j;
333 int i, k;
334 char *r;
335 time_t time_now = NOW;
336
337 for( i=0; i<256; ++i ) {
338 ot_vector *torrents_list = &all_torrents[i];
339 torrent_count += torrents_list->size;
340 }
341
342 if( !( r = *reply = malloc( 256*32 + 64*torrent_count ) ) ) return 0;
343
344 for( i=0; i<256; ++i )
345 r += sprintf( r, "%02X: %08X %08X\n", i, (ot_dword)all_torrents[i].size, (ot_dword)all_torrents[i].space );
346
347 for( i=0; i<256; ++i ) {
348 ot_vector *torrents_list = &all_torrents[i];
349 for( j=0; j<torrents_list->size; ++j ) {
350 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
351 ot_hash *hash =&( ((ot_torrent*)(torrents_list->data))[j] ).hash;
352 r += sprintf( r, "\n%s:\n", to_hex( (ot_byte*)hash ) );
353 clean_peerlist( time_now, peer_list );
354 for( k=0; k<OT_POOLS_COUNT; ++k )
355 r += sprintf( r, "\t%08X %08X\n", peer_list->peers[k].size, peer_list->peers[k].space );
356 }
357 }
358
359 return r - *reply;
360}
361
332/* Fetches scrape info for a specific torrent */ 362/* Fetches scrape info for a specific torrent */
333size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) { 363size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) {
334 char *r = reply; 364 char *r = reply;