summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index 6c988df..4f2ba68 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -290,6 +290,42 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned int amount, char
290 return r - reply; 290 return r - reply;
291} 291}
292 292
293/* Fetch full scrape info for all torrents */
294size_t return_fullscrape_for_tracker( char **reply ) {
295 int torrent_count = 0, i, j, k;
296 char* r;
297 time_t time_now = NOW;
298
299 for( i=0; i<256; ++i ) {
300 ot_vector *torrents_list = &all_torrents[i];
301 torrent_count += torrents_list->size;
302 }
303
304 r = *reply = malloc( 128*torrent_count );
305 if( !reply ) return 0;
306
307 memmove( r, "d5:filesd", 9 ); r += 9;
308 for( i=0; i<256; ++i ) {
309 ot_vector *torrents_list = &all_torrents[i];
310 for( j=0; j<torrents_list->size; ++j ) {
311 ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list;
312 ot_hash *hash =&( ((ot_torrent*)(torrents_list->data))[j] ).hash;
313 int peers = 0, seeds = 0;
314 clean_peerlist( time_now, peer_list );
315 for( k=0; k<OT_POOLS_COUNT; ++k ) {
316 peers += peer_list->peers[k].size;
317 seeds += peer_list->seed_count[k];
318 }
319 memmove( r, "20:", 3 ); r+=3;
320 memmove( r, hash, 20 ); r+=20;
321 r += sprintf( r, "d8:completei%de10:downloadedi%de10:incompletei%de", seeds, peer_list->downloaded, peers-seeds );
322 }
323 }
324
325 *r++='e'; *r++='e';
326 return r - *reply;
327}
328
293/* Fetches scrape info for a specific torrent */ 329/* Fetches scrape info for a specific torrent */
294size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) { 330size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) {
295 char *r = reply; 331 char *r = reply;