diff options
author | erdgeist <> | 2009-08-26 21:23:26 +0000 |
---|---|---|
committer | erdgeist <> | 2009-08-26 21:23:26 +0000 |
commit | 6073127ad0712bf925fd80982b68b072541824db (patch) | |
tree | d778c5c95b4ad568342b8aecb4f29a0137967090 /ot_http.c | |
parent | 20955311d12966b49b3cdf62217d7508af9a4e9a (diff) |
Add some subnet debugging features
Diffstat (limited to 'ot_http.c')
-rw-r--r-- | ot_http.c | 64 |
1 files changed, 62 insertions, 2 deletions
@@ -16,6 +16,7 @@ | |||
16 | #include "array.h" | 16 | #include "array.h" |
17 | #include "iob.h" | 17 | #include "iob.h" |
18 | #include "ip6.h" | 18 | #include "ip6.h" |
19 | #include "scan.h" | ||
19 | 20 | ||
20 | /* Opentracker */ | 21 | /* Opentracker */ |
21 | #include "trackerlogic.h" | 22 | #include "trackerlogic.h" |
@@ -168,7 +169,7 @@ static const ot_keywords keywords_mode[] = | |||
168 | { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, | 169 | { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, |
169 | { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, { "completed", TASK_STATS_COMPLETED }, | 170 | { "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, { "completed", TASK_STATS_COMPLETED }, |
170 | { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, | 171 | { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, |
171 | { "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TRACKERSTATE }, { NULL, -3 } }; | 172 | { "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TRACKERSTATE }, { "fulllog", TASK_STATS_FULLLOG }, { NULL, -3 } }; |
172 | static const ot_keywords keywords_format[] = | 173 | static const ot_keywords keywords_format[] = |
173 | { { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED }, | 174 | { { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED }, |
174 | { "txt", TASK_FULLSCRAPE_TPB_ASCII }, { NULL, -3 } }; | 175 | { "txt", TASK_FULLSCRAPE_TPB_ASCII }, { NULL, -3 } }; |
@@ -306,6 +307,9 @@ static ot_keywords keywords_announce[] = { { "port", 1 }, { "left", 2 }, { "even | |||
306 | #ifdef WANT_IP_FROM_QUERY_STRING | 307 | #ifdef WANT_IP_FROM_QUERY_STRING |
307 | { "ip", 7 }, | 308 | { "ip", 7 }, |
308 | #endif | 309 | #endif |
310 | #ifdef WANT_FULLLOG_NETWORKS | ||
311 | { "lognet", 8 }, | ||
312 | #endif | ||
309 | { NULL, -3 } }; | 313 | { NULL, -3 } }; |
310 | static ot_keywords keywords_announce_event[] = { { "completed", 1 }, { "stopped", 2 }, { NULL, -3 } }; | 314 | static ot_keywords keywords_announce_event[] = { { "completed", 1 }, { "stopped", 2 }, { NULL, -3 } }; |
311 | static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, char *read_ptr ) { | 315 | static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, char *read_ptr ) { |
@@ -412,6 +416,37 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, | |||
412 | } | 416 | } |
413 | break; | 417 | break; |
414 | #endif | 418 | #endif |
419 | #ifdef WANT_FULLLOG_NETWORKS | ||
420 | case 8: /* matched "lognet" */ | ||
421 | { | ||
422 | //if( accesslist_isblessed( cookie->ip, OT_PERMISSION_MAY_STAT ) ) { | ||
423 | char *tmp_buf = ws->reply; | ||
424 | ot_net net; | ||
425 | signed short parsed, bits; | ||
426 | |||
427 | len = scan_urlencoded_query( &read_ptr, tmp_buf, SCAN_SEARCHPATH_VALUE ); | ||
428 | tmp_buf[len] = 0; | ||
429 | if( len <= 0 ) HTTPERROR_400_PARAM; | ||
430 | if( *tmp_buf == '-' ) { | ||
431 | loglist_reset( ); | ||
432 | return ws->reply_size = sprintf( ws->reply, "Successfully removed.\n" ); | ||
433 | } | ||
434 | parsed = scan_ip6( tmp_buf, net.address ); | ||
435 | if( !parsed ) HTTPERROR_400_PARAM; | ||
436 | if( tmp_buf[parsed++] != '/' ) | ||
437 | bits = 128; | ||
438 | else { | ||
439 | parsed = scan_short( tmp_buf + parsed, &bits ); | ||
440 | if( !parsed ) HTTPERROR_400_PARAM; | ||
441 | if( ip6_isv4mapped( net.address ) ) | ||
442 | bits += 96; | ||
443 | } | ||
444 | net.bits = bits; | ||
445 | loglist_add_network( &net ); | ||
446 | return ws->reply_size = sprintf( ws->reply, "Successfully added.\n" ); | ||
447 | //} | ||
448 | } | ||
449 | #endif | ||
415 | } | 450 | } |
416 | } | 451 | } |
417 | 452 | ||
@@ -437,6 +472,31 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) { | |||
437 | ssize_t reply_off, len; | 472 | ssize_t reply_off, len; |
438 | char *read_ptr = ws->request, *write_ptr; | 473 | char *read_ptr = ws->request, *write_ptr; |
439 | 474 | ||
475 | #ifdef WANT_FULLLOG_NETWORKS | ||
476 | struct http_data *cookie = io_getcookie( sock ); | ||
477 | if( loglist_check_address( cookie->ip ) ) { | ||
478 | ot_log *log = malloc( sizeof( ot_log ) ); | ||
479 | printf( "Hello World\n" ); | ||
480 | if( log ) { | ||
481 | log->size = ws->request_size; | ||
482 | log->data = malloc( ws->request_size ); | ||
483 | log->next = 0; | ||
484 | log->time = g_now_seconds; | ||
485 | memcpy( log->ip, cookie->ip, sizeof(ot_ip6)); | ||
486 | if( log->data ) { | ||
487 | memcpy( log->data, ws->request, ws->request_size ); | ||
488 | if( !g_logchain_first ) | ||
489 | g_logchain_first = g_logchain_last = log; | ||
490 | else { | ||
491 | g_logchain_last->next = log; | ||
492 | g_logchain_last = log; | ||
493 | } | ||
494 | } else | ||
495 | free( log ); | ||
496 | } | ||
497 | } | ||
498 | #endif | ||
499 | |||
440 | #ifdef _DEBUG_HTTPERROR | 500 | #ifdef _DEBUG_HTTPERROR |
441 | reply_off = ws->request_size; | 501 | reply_off = ws->request_size; |
442 | if( ws->request_size >= G_DEBUGBUF_SIZE ) | 502 | if( ws->request_size >= G_DEBUGBUF_SIZE ) |
@@ -444,7 +504,7 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) { | |||
444 | memcpy( ws->debugbuf, ws->request, reply_off ); | 504 | memcpy( ws->debugbuf, ws->request, reply_off ); |
445 | ws->debugbuf[ reply_off ] = 0; | 505 | ws->debugbuf[ reply_off ] = 0; |
446 | #endif | 506 | #endif |
447 | 507 | ||
448 | /* Tell subroutines where to put reply data */ | 508 | /* Tell subroutines where to put reply data */ |
449 | ws->reply = ws->outbuf + SUCCESS_HTTP_HEADER_LENGTH; | 509 | ws->reply = ws->outbuf + SUCCESS_HTTP_HEADER_LENGTH; |
450 | 510 | ||