提交 5bb381e2 编写于 作者: D denis

new modes for udp4 and tcp4 stats

上级 50fe661a
......@@ -246,18 +246,42 @@ static void httpresponse( const int64 s, char *data ) {
mode = STATS_TOP5;
else if( !byte_diff(data,4,"dmem"))
mode = STATS_DMEM;
else if( !byte_diff(data,4,"tcp4"))
mode = STATS_TCP;
else if( !byte_diff(data,4,"udp4"))
mode = STATS_UDP;
else
HTTPERROR_400_PARAM;
}
}
if( mode == STATS_DMEM ) {
if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500;
return sendmallocdata( s, reply, reply_size );
}
switch( mode)
{
case STATS_DMEM:
if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500;
return sendmallocdata( s, reply, reply_size );
case STATS_UDP:
t = time( NULL ) - ot_start_time;
reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH,
"%i\n%i\n%i seconds (%i hours)\nopentracker udp stats.",
ot_overall_connections, ot_overall_udp_successfulannounces, (int)t, (int)(t / 3600) );
break;
/* Enough for http header + whole scrape string */
if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500;
case STATS_TCP:
t = time( NULL ) - ot_start_time;
reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH,
"%i\n%i\n%i seconds (%i hours)\nopentracker tcp stats.",
ot_overall_connections, ot_overall_tcp_successfulannounces, (int)t, (int)(t / 3600) );
break;
default:
case STATS_MRTG:
/* Enough for http header + whole scrape string */
if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500;
break;
}
break;
case 6: /* scrape ? */
if( byte_diff( data, 6, "scrape") ) HTTPERROR_404;
......
......@@ -91,7 +91,7 @@ extern int g_closedtracker;
extern int g_check_blacklist;
#endif
enum { STATS_MRTG, STATS_TOP5, STATS_DMEM };
enum { STATS_MRTG, STATS_TOP5, STATS_DMEM, STATS_TCP, STATS_UDP };
ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer );
size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply, int is_tcp );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册