mirror of
git://erdgeist.org/opentracker
synced 2025-04-04 04:17:15 +08:00
new modes for udp4 and tcp4 stats
This commit is contained in:
parent
50fe661aa7
commit
5bb381e20a
@ -246,19 +246,43 @@ static void httpresponse( const int64 s, char *data ) {
|
|||||||
mode = STATS_TOP5;
|
mode = STATS_TOP5;
|
||||||
else if( !byte_diff(data,4,"dmem"))
|
else if( !byte_diff(data,4,"dmem"))
|
||||||
mode = STATS_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
|
else
|
||||||
HTTPERROR_400_PARAM;
|
HTTPERROR_400_PARAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mode == STATS_DMEM ) {
|
switch( mode)
|
||||||
|
{
|
||||||
|
case STATS_DMEM:
|
||||||
if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500;
|
if( !( reply_size = return_memstat_for_tracker( &reply ) ) ) HTTPERROR_500;
|
||||||
return sendmallocdata( s, reply, reply_size );
|
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;
|
||||||
|
|
||||||
|
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 */
|
/* Enough for http header + whole scrape string */
|
||||||
if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500;
|
if( !( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, mode ) ) ) HTTPERROR_500;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
case 6: /* scrape ? */
|
case 6: /* scrape ? */
|
||||||
if( byte_diff( data, 6, "scrape") ) HTTPERROR_404;
|
if( byte_diff( data, 6, "scrape") ) HTTPERROR_404;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ extern int g_closedtracker;
|
|||||||
extern int g_check_blacklist;
|
extern int g_check_blacklist;
|
||||||
#endif
|
#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 );
|
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 );
|
size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply, int is_tcp );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user