diff options
-rw-r--r-- | opentracker.c | 15 | ||||
-rw-r--r-- | trackerlogic.c | 4 |
2 files changed, 13 insertions, 6 deletions
diff --git a/opentracker.c b/opentracker.c index 1bd8514..f592fd5 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -19,7 +19,8 @@ | |||
19 | #include "trackerlogic.h" | 19 | #include "trackerlogic.h" |
20 | #include "scan_urlencoded_query.h" | 20 | #include "scan_urlencoded_query.h" |
21 | 21 | ||
22 | static unsigned int overall_connections = 0; | 22 | static unsigned int ot_overall_connections = 0; |
23 | static time_t ot_start_time; | ||
23 | 24 | ||
24 | static void carp(const char* routine) { | 25 | static void carp(const char* routine) { |
25 | buffer_puts(buffer_2,routine); | 26 | buffer_puts(buffer_2,routine); |
@@ -282,10 +283,14 @@ e500: | |||
282 | } | 283 | } |
283 | break; | 284 | break; |
284 | case 11: | 285 | case 11: |
285 | if( byte_diff(data,11,",mrtg_scrape")) | 286 | if( byte_diff(data,11,"mrtg_scrape")) |
286 | goto e404; | 287 | goto e404; |
287 | reply = malloc( 128 ); | 288 | reply = malloc( 128 ); |
288 | reply_size = sprintf( reply, "%d\n%d\nUp: 23 years.\nPertuned by german engineers.", overall_connections, overall_connections ); | 289 | { |
290 | unsigned long seconds_elapsed = time( NULL ) - ot_start_time; | ||
291 | reply_size = sprintf( reply, "%d\n%d\nUp: %ld seconds (%ld hours)\nPertuned by german engineers, currently handling %li connections per second.", | ||
292 | ot_overall_connections, ot_overall_connections, seconds_elapsed, seconds_elapsed / 3600, ot_overall_connections / seconds_elapsed ? seconds_elapsed : 1 ); | ||
293 | } | ||
289 | break; | 294 | break; |
290 | default: /* neither *scrape nor announce */ | 295 | default: /* neither *scrape nor announce */ |
291 | e404: | 296 | e404: |
@@ -322,6 +327,8 @@ int main() | |||
322 | unsigned long ip; | 327 | unsigned long ip; |
323 | uint16 port; | 328 | uint16 port; |
324 | 329 | ||
330 | ot_start_time = time( NULL ); | ||
331 | |||
325 | if (socket_bind4_reuse(s,NULL,6969)==-1) | 332 | if (socket_bind4_reuse(s,NULL,6969)==-1) |
326 | panic("socket_bind4_reuse"); | 333 | panic("socket_bind4_reuse"); |
327 | 334 | ||
@@ -359,7 +366,7 @@ int main() | |||
359 | byte_zero(h,sizeof(struct http_data)); | 366 | byte_zero(h,sizeof(struct http_data)); |
360 | h->ip=ip; | 367 | h->ip=ip; |
361 | io_setcookie(n,h); | 368 | io_setcookie(n,h); |
362 | ++overall_connections; | 369 | ++ot_overall_connections; |
363 | } else | 370 | } else |
364 | io_close(n); | 371 | io_close(n); |
365 | } else | 372 | } else |
diff --git a/trackerlogic.c b/trackerlogic.c index b9f14f0..e9b9b2e 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -203,7 +203,7 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char | |||
203 | } | 203 | } |
204 | if( peer_count < amount ) amount = peer_count; | 204 | if( peer_count < amount ) amount = peer_count; |
205 | 205 | ||
206 | r += FORMAT_FORMAT_STRING( r, "d5:peers%li:",6*amount ); | 206 | r += FORMAT_FORMAT_STRING( r, "d8:completei%lie10:incompletei%lie8:intervali60e5:peers%li:", seed_count, peer_count-seed_count, 6*amount ); |
207 | for( index = 0; index < amount; ++index ) { | 207 | for( index = 0; index < amount; ++index ) { |
208 | double step = 1.8*((double)( peer_count - wert - 1 ))/((double)( amount - index )); | 208 | double step = 1.8*((double)( peer_count - wert - 1 ))/((double)( amount - index )); |
209 | int off = random() % (int)floor( step ); | 209 | int off = random() % (int)floor( step ); |
@@ -222,7 +222,7 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char | |||
222 | MEMMOVE( r, ((ot_peer*)torrent->peer_list->peers[pool_index].data) + pool_offset, 6 ); | 222 | MEMMOVE( r, ((ot_peer*)torrent->peer_list->peers[pool_index].data) + pool_offset, 6 ); |
223 | r += 6; | 223 | r += 6; |
224 | } | 224 | } |
225 | r += FORMAT_FORMAT_STRING( r, "8:completei%lie10:incompletei%lie8:intervali60ee", seed_count, peer_count-seed_count ); | 225 | *r++ = 'e'; |
226 | 226 | ||
227 | return r - reply; | 227 | return r - reply; |
228 | } | 228 | } |