summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
authordenis <>2007-03-16 22:46:41 +0000
committerdenis <>2007-03-16 22:46:41 +0000
commit8ac7768b961d3ef90e4b4b7ac6fc6b2322f1aa7f (patch)
tree74c65ac90cc8a91e5b4d766c732cc33569cd9f54 /trackerlogic.c
parent36413e4853a02b7adbd192d362c4c091330e5e88 (diff)
support for udp scrape
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index bc9010e..ff6f45a 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -408,7 +408,33 @@ size_t return_memstat_for_tracker( char **reply ) {
408} 408}
409 409
410/* Fetches scrape info for a specific torrent */ 410/* Fetches scrape info for a specific torrent */
411size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) { 411size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) {
412 int exactmatch, i;
413 size_t peers = 0, seeds = 0;
414 ot_vector *torrents_list = &all_torrents[*hash[0]];
415 ot_torrent *torrent = binary_search( hash, torrents_list->data, torrents_list->size, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch );
416
417 if( !exactmatch ) {
418 memset( reply, 0, 12);
419 }
420 else
421 {
422 unsigned long *r = (unsigned long*) reply;
423 clean_peerlist( NOW, torrent->peer_list );
424
425 for( i=0; i<OT_POOLS_COUNT; ++i ) {
426 peers += torrent->peer_list->peers[i].size;
427 seeds += torrent->peer_list->seed_count[i];
428 }
429 r[0] = seeds;
430 r[1] = torrent->peer_list->downloaded;
431 r[2] = peers-seeds;
432 }
433 return 12;
434}
435
436/* Fetches scrape info for a specific torrent */
437size_t return_tcp_scrape_for_torrent( ot_hash *hash, char *reply ) {
412 char *r = reply; 438 char *r = reply;
413 int exactmatch, i; 439 int exactmatch, i;
414 size_t peers = 0, seeds = 0; 440 size_t peers = 0, seeds = 0;