From 8ac7768b961d3ef90e4b4b7ac6fc6b2322f1aa7f Mon Sep 17 00:00:00 2001 From: denis <> Date: Fri, 16 Mar 2007 22:46:41 +0000 Subject: support for udp scrape --- trackerlogic.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'trackerlogic.c') 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 ) { } /* Fetches scrape info for a specific torrent */ -size_t return_scrape_for_torrent( ot_hash *hash, char *reply ) { +size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) { + int exactmatch, i; + size_t peers = 0, seeds = 0; + ot_vector *torrents_list = &all_torrents[*hash[0]]; + ot_torrent *torrent = binary_search( hash, torrents_list->data, torrents_list->size, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch ); + + if( !exactmatch ) { + memset( reply, 0, 12); + } + else + { + unsigned long *r = (unsigned long*) reply; + clean_peerlist( NOW, torrent->peer_list ); + + for( i=0; ipeer_list->peers[i].size; + seeds += torrent->peer_list->seed_count[i]; + } + r[0] = seeds; + r[1] = torrent->peer_list->downloaded; + r[2] = peers-seeds; + } + return 12; +} + +/* Fetches scrape info for a specific torrent */ +size_t return_tcp_scrape_for_torrent( ot_hash *hash, char *reply ) { char *r = reply; int exactmatch, i; size_t peers = 0, seeds = 0; -- cgit v1.2.3