summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ot_http.c24
-rw-r--r--ot_mutex.h35
2 files changed, 41 insertions, 18 deletions
diff --git a/ot_http.c b/ot_http.c
index 5b84b7f..362b2ab 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -214,6 +214,12 @@ static ssize_t http_handle_sync( const int64 client_socket, char *data ) {
214static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d, size_t l ) { 214static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d, size_t l ) {
215 char *c = data; 215 char *c = data;
216 int mode = TASK_STATS_PEERS, scanon = 1, format = 0; 216 int mode = TASK_STATS_PEERS, scanon = 1, format = 0;
217#ifdef WANT_RESTRICT_STATS
218 struct http_data *h = io_getcookie( client_socket );
219
220 if( !accesslist_isblessed( h->ip, OT_PERMISSION_MAY_STAT ) )
221 HTTPERROR_403_IP;
222#endif
217 223
218 while( scanon ) { 224 while( scanon ) {
219 switch( scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_PARAM ) ) { 225 switch( scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_PARAM ) ) {
@@ -230,8 +236,8 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
230 mode = TASK_STATS_PEERS; 236 mode = TASK_STATS_PEERS;
231 else if( !byte_diff(data,4,"conn")) 237 else if( !byte_diff(data,4,"conn"))
232 mode = TASK_STATS_CONNS; 238 mode = TASK_STATS_CONNS;
233 else if( !byte_diff(data,4,"top5")) 239 else if( !byte_diff(data,4,"top10"))
234 mode = TASK_STATS_TOP5; 240 mode = TASK_STATS_TOP10;
235 else if( !byte_diff(data,4,"scrp")) 241 else if( !byte_diff(data,4,"scrp"))
236 mode = TASK_STATS_SCRAPE; 242 mode = TASK_STATS_SCRAPE;
237 else if( !byte_diff(data,4,"torr")) 243 else if( !byte_diff(data,4,"torr"))
@@ -256,6 +262,10 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
256 mode = TASK_STATS_VERSION; 262 mode = TASK_STATS_VERSION;
257 else if( !byte_diff(data,4,"busy")) 263 else if( !byte_diff(data,4,"busy"))
258 mode = TASK_STATS_BUSY_NETWORKS; 264 mode = TASK_STATS_BUSY_NETWORKS;
265 else if( !byte_diff(data,4,"dmem"))
266 mode = TASK_STATS_MEMORY;
267 else if( !byte_diff(data,4,"vdeb"))
268 mode = TASK_STATS_VECTOR_DEBUG;
259 else 269 else
260 HTTPERROR_400_PARAM; 270 HTTPERROR_400_PARAM;
261 break; 271 break;
@@ -304,7 +314,17 @@ static ssize_t http_handle_stats( const int64 client_socket, char *data, char *d
304#endif 314#endif
305 315
306 /* default format for now */ 316 /* default format for now */
317 if( ( mode & TASK_CLASS_MASK ) == TASK_STATS ) {
318 tai6464 t;
319 /* Complex stats also include expensive memory debugging tools */
320 taia_uint( &t, 0 ); io_timeout( client_socket, t );
321 stats_deliver( client_socket, mode );
322 return -2;
323 }
324
325 /* Simple stats can be answerred immediately */
307 if( !( l = return_stats_for_tracker( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, mode, 0 ) ) ) HTTPERROR_500; 326 if( !( l = return_stats_for_tracker( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, mode, 0 ) ) ) HTTPERROR_500;
327
308 return l; 328 return l;
309} 329}
310 330
diff --git a/ot_mutex.h b/ot_mutex.h
index 17cb5b4..5865765 100644
--- a/ot_mutex.h
+++ b/ot_mutex.h
@@ -16,22 +16,25 @@ void mutex_bucket_unlock( int bucket );
16void mutex_bucket_unlock_by_hash( ot_hash *hash ); 16void mutex_bucket_unlock_by_hash( ot_hash *hash );
17 17
18typedef enum { 18typedef enum {
19 TASK_STATS_CONNS = 0x0000, 19 TASK_STATS_CONNS = 0x0001,
20 TASK_STATS_PEERS = 0x0001, 20 TASK_STATS_TCP = 0x0002,
21 TASK_STATS_TOP5 = 0x0002, 21 TASK_STATS_UDP = 0x0003,
22 TASK_STATS_TCP = 0x0003, 22 TASK_STATS_SCRAPE = 0x0004,
23 TASK_STATS_UDP = 0x0004, 23 TASK_STATS_FULLSCRAPE = 0x0005,
24 TASK_STATS_SCRAPE = 0x0005, 24 TASK_STATS_TPB = 0x0006,
25 TASK_STATS_FULLSCRAPE = 0x0006, 25 TASK_STATS_HTTPERRORS = 0x0007,
26 TASK_STATS_TPB = 0x0007, 26 TASK_STATS_STARTSTOP = 0x0008,
27 TASK_STATS_HTTPERRORS = 0x0008, 27 TASK_STATS_TORADDREM = 0x0009,
28 TASK_STATS_TORRENTS = 0x0009, 28 TASK_STATS_VERSION = 0x000a,
29 TASK_STATS_STARTSTOP = 0x000a, 29 TASK_STATS_BUSY_NETWORKS = 0x000b,
30 TASK_STATS_TORADDREM = 0x000b, 30 TASK_STATS_VECTOR_DEBUG = 0x000c,
31 TASK_STATS_VERSION = 0x000c, 31
32 TASK_STATS_BUSY_NETWORKS = 0x000d, 32 TASK_STATS = 0x0100, /* Mask */
33 33 TASK_STATS_TORRENTS = 0x0101,
34 TASK_STATS_SLASH24S = 0x0100, 34 TASK_STATS_PEERS = 0x0102,
35 TASK_STATS_SLASH24S = 0x0103,
36 TASK_STATS_TOP10 = 0x0104,
37 TASK_STATS_MEMORY = 0x0105,
35 38
36 TASK_FULLSCRAPE = 0x0200, /* Default mode */ 39 TASK_FULLSCRAPE = 0x0200, /* Default mode */
37 TASK_FULLSCRAPE_TPB_BINARY = 0x0201, 40 TASK_FULLSCRAPE_TPB_BINARY = 0x0201,