summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c15
1 files changed, 11 insertions, 4 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
22static unsigned int overall_connections = 0; 22static unsigned int ot_overall_connections = 0;
23static time_t ot_start_time;
23 24
24static void carp(const char* routine) { 25static 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 */
291e404: 296e404:
@@ -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