summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/opentracker.c b/opentracker.c
index 29af881..c8c3cd5 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -29,7 +29,8 @@
29#include "scan_urlencoded_query.h" 29#include "scan_urlencoded_query.h"
30 30
31/* Globals */ 31/* Globals */
32static unsigned int ot_overall_connections = 0; 32static unsigned int ot_overall_tcp_connections = 0;
33static unsigned int ot_overall_udp_connections = 0;
33static unsigned int ot_overall_tcp_successfulannounces = 0; 34static unsigned int ot_overall_tcp_successfulannounces = 0;
34static unsigned int ot_overall_udp_successfulannounces = 0; 35static unsigned int ot_overall_udp_successfulannounces = 0;
35static time_t ot_start_time; 36static time_t ot_start_time;
@@ -264,15 +265,15 @@ static void httpresponse( const int64 s, char *data ) {
264 case STATS_UDP: 265 case STATS_UDP:
265 t = time( NULL ) - ot_start_time; 266 t = time( NULL ) - ot_start_time;
266 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, 267 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH,
267 "%i\n%i\n%i seconds (%i hours)\nopentracker udp stats.", 268 "%i\n%i\n%i seconds (%i hours)\nopentracker udp4 stats.",
268 ot_overall_connections, ot_overall_udp_successfulannounces, (int)t, (int)(t / 3600) ); 269 ot_overall_udp_connections, ot_overall_udp_successfulannounces, (int)t, (int)(t / 3600) );
269 break; 270 break;
270 271
271 case STATS_TCP: 272 case STATS_TCP:
272 t = time( NULL ) - ot_start_time; 273 t = time( NULL ) - ot_start_time;
273 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, 274 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH,
274 "%i\n%i\n%i seconds (%i hours)\nopentracker tcp stats.", 275 "%i\n%i\n%i seconds (%i hours)\nopentracker tcp4 stats.",
275 ot_overall_connections, ot_overall_tcp_successfulannounces, (int)t, (int)(t / 3600) ); 276 ot_overall_tcp_connections, ot_overall_tcp_successfulannounces, (int)t, (int)(t / 3600) );
276 break; 277 break;
277 278
278 default: 279 default:
@@ -281,7 +282,7 @@ static void httpresponse( const int64 s, char *data ) {
281 if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500; 282 if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500;
282 break; 283 break;
283 } 284 }
284 285
285 break; 286 break;
286 case 6: /* scrape ? */ 287 case 6: /* scrape ? */
287 if( byte_diff( data, 6, "scrape") ) HTTPERROR_404; 288 if( byte_diff( data, 6, "scrape") ) HTTPERROR_404;
@@ -419,7 +420,7 @@ ANNOUNCE_WORKAROUND:
419 t = time( NULL ) - ot_start_time; 420 t = time( NULL ) - ot_start_time;
420 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, 421 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH,
421 "%i\n%i\n%i seconds (%i hours)\nopentracker - Pretuned by german engineers, currently handling %i connections per second.", 422 "%i\n%i\n%i seconds (%i hours)\nopentracker - Pretuned by german engineers, currently handling %i connections per second.",
422 ot_overall_connections, ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) ); 423 ot_overall_tcp_connections+ot_overall_udp_connections, ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_tcp_connections / ( (int)t ? (int)t : 1 ) );
423 break; 424 break;
424 case 12: 425 case 12:
425 if( byte_diff( data, 12, "announce.php" ) ) HTTPERROR_404; 426 if( byte_diff( data, 12, "announce.php" ) ) HTTPERROR_404;
@@ -558,7 +559,7 @@ static void handle_accept( const int64 serversocket ) {
558 byte_zero(h,sizeof(struct http_data)); 559 byte_zero(h,sizeof(struct http_data));
559 memmove(h->ip,ip,sizeof(ip)); 560 memmove(h->ip,ip,sizeof(ip));
560 io_setcookie(i,h); 561 io_setcookie(i,h);
561 ++ot_overall_connections; 562 ++ot_overall_tcp_connections;
562 taia_now(&t); 563 taia_now(&t);
563 taia_addsec(&t,&t,OT_CLIENT_TIMEOUT); 564 taia_addsec(&t,&t,OT_CLIENT_TIMEOUT);
564 io_timeout(i,t); 565 io_timeout(i,t);
@@ -593,6 +594,8 @@ static void handle_udp4( int64 serversocket ) {
593 594
594 r = socket_recv4( serversocket, static_inbuf, 8192, remoteip, &remoteport); 595 r = socket_recv4( serversocket, static_inbuf, 8192, remoteip, &remoteport);
595 596
597 ot_overall_udp_connections++;
598
596 /* Minimum udp tracker packet size, also catches error */ 599 /* Minimum udp tracker packet size, also catches error */
597 if( r < 16 ) 600 if( r < 16 )
598 return; 601 return;