summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
authordenis <>2007-03-15 21:32:14 +0000
committerdenis <>2007-03-15 21:32:14 +0000
commitf2a0c367214cbfa0627c134c50ea6d78550cc2b6 (patch)
treea6bf3a1f47834b6185c990742495ed21e537ecac /opentracker.c
parent036e874ed431b9f53a16afb568790d03cf6f1fc2 (diff)
collecting stats for udp connections
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/opentracker.c b/opentracker.c
index d8d960b..f753048 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -30,7 +30,8 @@
30 30
31/* Globals */ 31/* Globals */
32static unsigned int ot_overall_connections = 0; 32static unsigned int ot_overall_connections = 0;
33static unsigned int ot_overall_successfulannounces = 0; 33static unsigned int ot_overall_tcp_successfulannounces = 0;
34static unsigned int ot_overall_udp_successfulannounces = 0;
34static time_t ot_start_time; 35static time_t ot_start_time;
35static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; 36static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80;
36static const size_t SUCCESS_HTTP_SIZE_OFF = 17; 37static const size_t SUCCESS_HTTP_SIZE_OFF = 17;
@@ -284,14 +285,14 @@ SCRAPE_WORKAROUND:
284 /* Scanned whole query string, no hash means full scrape... you might want to limit that */ 285 /* Scanned whole query string, no hash means full scrape... you might want to limit that */
285 if( !hash ) { 286 if( !hash ) {
286 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; 287 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500;
287 ot_overall_successfulannounces++; 288 ot_overall_tcp_successfulannounces++;
288 return sendmallocdata( s, reply, reply_size ); 289 return sendmallocdata( s, reply, reply_size );
289 } 290 }
290 291
291 /* Enough for http header + whole scrape string */ 292 /* Enough for http header + whole scrape string */
292 if( !( reply_size = return_scrape_for_torrent( hash, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf ) ) ) HTTPERROR_500; 293 if( !( reply_size = return_scrape_for_torrent( hash, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf ) ) ) HTTPERROR_500;
293 294
294 ot_overall_successfulannounces++; 295 ot_overall_tcp_successfulannounces++;
295 break; 296 break;
296 case 8: 297 case 8:
297 if( byte_diff( data, 8, "announce" ) ) HTTPERROR_404; 298 if( byte_diff( data, 8, "announce" ) ) HTTPERROR_404;
@@ -383,7 +384,7 @@ ANNOUNCE_WORKAROUND:
383 torrent = add_peer_to_torrent( hash, &peer ); 384 torrent = add_peer_to_torrent( hash, &peer );
384 if( !torrent || !( reply_size = return_peers_for_torrent( torrent, numwant, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, 1 ) ) ) HTTPERROR_500; 385 if( !torrent || !( reply_size = return_peers_for_torrent( torrent, numwant, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, 1 ) ) ) HTTPERROR_500;
385 } 386 }
386 ot_overall_successfulannounces++; 387 ot_overall_tcp_successfulannounces++;
387 break; 388 break;
388 case 10: 389 case 10:
389 if( byte_diff( data, 10, "scrape.php" ) ) HTTPERROR_404; 390 if( byte_diff( data, 10, "scrape.php" ) ) HTTPERROR_404;
@@ -394,7 +395,7 @@ ANNOUNCE_WORKAROUND:
394 t = time( NULL ) - ot_start_time; 395 t = time( NULL ) - ot_start_time;
395 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, 396 reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH,
396 "%i\n%i\n%i seconds (%i hours)\nopentracker - Pretuned by german engineers, currently handling %i connections per second.", 397 "%i\n%i\n%i seconds (%i hours)\nopentracker - Pretuned by german engineers, currently handling %i connections per second.",
397 ot_overall_connections, ot_overall_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) ); 398 ot_overall_connections, ot_overall_tcp_successfulannounces+ot_overall_tcp_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) );
398 break; 399 break;
399 case 12: 400 case 12:
400 if( byte_diff( data, 12, "announce.php" ) ) HTTPERROR_404; 401 if( byte_diff( data, 12, "announce.php" ) ) HTTPERROR_404;
@@ -621,6 +622,7 @@ static void handle_udp4( int64 serversocket ) {
621 outpacket[1] = inpacket[12/4]; 622 outpacket[1] = inpacket[12/4];
622 r = 8 + return_peers_for_torrent( torrent, numwant, static_outbuf + 8, 0 ); 623 r = 8 + return_peers_for_torrent( torrent, numwant, static_outbuf + 8, 0 );
623 socket_send4( serversocket, static_outbuf, r, remoteip, remoteport ); 624 socket_send4( serversocket, static_outbuf, r, remoteip, remoteport );
625 ot_overall_udp_successfulannounces++;
624 } 626 }
625 break; 627 break;
626 } 628 }