diff options
Diffstat (limited to 'trackerlogic.c')
-rw-r--r-- | trackerlogic.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 901697d..0c78e16 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -310,6 +310,28 @@ size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) { | |||
310 | return r - reply; | 310 | return r - reply; |
311 | } | 311 | } |
312 | 312 | ||
313 | /* Fetches stats from tracker */ | ||
314 | size_t return_stats_for_tracker( char *reply ) { | ||
315 | int torrent_count = 0, peer_count = 0, seed_count = 0; | ||
316 | char *r = reply; | ||
317 | int i,j,k; | ||
318 | |||
319 | for( i=0; i<256; ++i ) { | ||
320 | ot_vector *torrents_list = &all_torrents[i]; | ||
321 | torrent_count += torrents_list->size; | ||
322 | for( j=0; j<torrents_list->size; ++j ) { | ||
323 | ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; | ||
324 | for( k=0; k<OT_POOLS_COUNT; ++k ) { | ||
325 | peer_count += peer_list->peers[k].size; | ||
326 | seed_count += peer_list->seed_count[k]; | ||
327 | } | ||
328 | } | ||
329 | } | ||
330 | r += sprintf( r, "%i\n%i\nopentracker serving %i torrents\nSomething else.", peer_count, seed_count, torrent_count ); | ||
331 | |||
332 | return r - reply; | ||
333 | } | ||
334 | |||
313 | void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ) { | 335 | void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ) { |
314 | int exactmatch, i; | 336 | int exactmatch, i; |
315 | ot_vector *torrents_list = &all_torrents[*hash[0]]; | 337 | ot_vector *torrents_list = &all_torrents[*hash[0]]; |