diff options
-rw-r--r-- | trackerlogic.c | 41 | ||||
-rw-r--r-- | trackerlogic.h | 3 |
2 files changed, 0 insertions, 44 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 846b54e..7f28903 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -226,47 +226,6 @@ void fix_mmapallocation( void *buf, size_t old_alloc, size_t new_alloc ) { | |||
226 | munmap( ((char*)buf) + new_pages * page_size, old_alloc - new_pages * page_size ); | 226 | munmap( ((char*)buf) + new_pages * page_size, old_alloc - new_pages * page_size ); |
227 | } | 227 | } |
228 | 228 | ||
229 | /* Fetch full scrape info for all torrents */ | ||
230 | size_t return_fullscrape_for_tracker( char **reply ) { | ||
231 | size_t torrent_count = 0, j; | ||
232 | size_t allocated, replysize; | ||
233 | ot_vector *torrents_list; | ||
234 | int bucket; | ||
235 | char *r; | ||
236 | |||
237 | for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) { | ||
238 | ot_vector *torrents_list = mutex_bucket_lock( bucket ); | ||
239 | torrent_count += torrents_list->size; | ||
240 | mutex_bucket_unlock( bucket ); | ||
241 | } | ||
242 | |||
243 | /* one extra for pro- and epilogue */ | ||
244 | allocated = 100*(1+torrent_count); | ||
245 | if( !( r = *reply = mmap( NULL, allocated, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0 ) ) ) return 0; | ||
246 | |||
247 | memmove( r, "d5:filesd", 9 ); r += 9; | ||
248 | for( bucket=0; bucket<OT_BUCKET_COUNT; ++bucket ) { | ||
249 | torrents_list = mutex_bucket_lock( bucket ); | ||
250 | for( j=0; j<torrents_list->size; ++j ) { | ||
251 | ot_peerlist *peer_list = ( ((ot_torrent*)(torrents_list->data))[j] ).peer_list; | ||
252 | ot_hash *hash =&( ((ot_torrent*)(torrents_list->data))[j] ).hash; | ||
253 | if( peer_list->peer_count || peer_list->down_count ) { | ||
254 | *r++='2'; *r++='0'; *r++=':'; | ||
255 | memmove( r, hash, 20 ); r+=20; | ||
256 | r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee", peer_list->seed_count, peer_list->down_count, peer_list->peer_count-peer_list->seed_count ); | ||
257 | } | ||
258 | } | ||
259 | mutex_bucket_unlock( bucket ); | ||
260 | } | ||
261 | |||
262 | *r++='e'; *r++='e'; | ||
263 | |||
264 | replysize = ( r - *reply ); | ||
265 | fix_mmapallocation( *reply, allocated, replysize ); | ||
266 | |||
267 | return replysize; | ||
268 | } | ||
269 | |||
270 | /* Fetches scrape info for a specific torrent */ | 229 | /* Fetches scrape info for a specific torrent */ |
271 | size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) { | 230 | size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ) { |
272 | int exactmatch; | 231 | int exactmatch; |
diff --git a/trackerlogic.h b/trackerlogic.h index 9c13a62..b216e50 100644 --- a/trackerlogic.h +++ b/trackerlogic.h | |||
@@ -17,7 +17,6 @@ typedef uint16_t ot_word; | |||
17 | typedef uint32_t ot_dword; | 17 | typedef uint32_t ot_dword; |
18 | 18 | ||
19 | typedef ot_byte ot_hash[20]; | 19 | typedef ot_byte ot_hash[20]; |
20 | typedef ot_dword ot_ip; | ||
21 | typedef time_t ot_time; | 20 | typedef time_t ot_time; |
22 | 21 | ||
23 | /* Some tracker behaviour tunable */ | 22 | /* Some tracker behaviour tunable */ |
@@ -43,7 +42,6 @@ typedef time_t ot_time; | |||
43 | /* This list points to 9 pools of peers each grouped in five-minute-intervals | 42 | /* This list points to 9 pools of peers each grouped in five-minute-intervals |
44 | thus achieving a timeout of 2700s or 45 minutes | 43 | thus achieving a timeout of 2700s or 45 minutes |
45 | These pools are sorted by its binary content */ | 44 | These pools are sorted by its binary content */ |
46 | |||
47 | #define OT_POOLS_COUNT 9 | 45 | #define OT_POOLS_COUNT 9 |
48 | #define OT_POOLS_TIMEOUT (60*5) | 46 | #define OT_POOLS_TIMEOUT (60*5) |
49 | 47 | ||
@@ -105,7 +103,6 @@ void trackerlogic_deinit( void ); | |||
105 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_TRACKER_SYNC_PARAM( int from_changeset ) ); | 103 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_TRACKER_SYNC_PARAM( int from_changeset ) ); |
106 | size_t remove_peer_from_torrent( ot_hash *hash, ot_peer *peer, char *reply, int is_tcp ); | 104 | size_t remove_peer_from_torrent( ot_hash *hash, ot_peer *peer, char *reply, int is_tcp ); |
107 | size_t return_peers_for_torrent( ot_hash *hash, size_t amount, char *reply, int is_tcp ); | 105 | size_t return_peers_for_torrent( ot_hash *hash, size_t amount, char *reply, int is_tcp ); |
108 | size_t return_fullscrape_for_tracker( char **reply ); | ||
109 | size_t return_tcp_scrape_for_torrent( ot_hash *hash, int amount, char *reply ); | 106 | size_t return_tcp_scrape_for_torrent( ot_hash *hash, int amount, char *reply ); |
110 | size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ); | 107 | size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ); |
111 | void clean_all_torrents( void ); | 108 | void clean_all_torrents( void ); |