summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--ot_accesslist.c28
-rw-r--r--ot_accesslist.h16
-rw-r--r--ot_http.c68
-rw-r--r--ot_stats.c42
-rw-r--r--ot_workqueue.h1
-rw-r--r--tests/integration/test_stats.py4
-rw-r--r--trackerlogic.h4
8 files changed, 4 insertions, 161 deletions
diff --git a/Makefile b/Makefile
index 6a5a270..92e911d 100644
--- a/Makefile
+++ b/Makefile
@@ -36,10 +36,8 @@ include Makefile.gzip
36# in Makefile.zstd 36# in Makefile.zstd
37#include Makefile.zstd 37#include Makefile.zstd
38 38
39#FEATURES+=-DWANT_LOG_NETWORKS
40#FEATURES+=-DWANT_RESTRICT_STATS 39#FEATURES+=-DWANT_RESTRICT_STATS
41#FEATURES+=-DWANT_IP_FROM_PROXY 40#FEATURES+=-DWANT_IP_FROM_PROXY
42#FEATURES+=-DWANT_FULLLOG_NETWORKS
43#FEATURES+=-DWANT_LOG_NUMWANT 41#FEATURES+=-DWANT_LOG_NUMWANT
44#FEATURES+=-DWANT_MODEST_FULLSCRAPES 42#FEATURES+=-DWANT_MODEST_FULLSCRAPES
45#FEATURES+=-DWANT_SPOT_WOODPECKER 43#FEATURES+=-DWANT_SPOT_WOODPECKER
diff --git a/ot_accesslist.c b/ot_accesslist.c
index df084b8..945ddcf 100644
--- a/ot_accesslist.c
+++ b/ot_accesslist.c
@@ -503,34 +503,6 @@ void *accesslist_get_value_for_net(const ot_ip6 address, const ot_vector *vector
503 return (void *)net; 503 return (void *)net;
504} 504}
505 505
506#ifdef WANT_FULLLOG_NETWORKS
507static ot_vector g_lognets_list;
508ot_log *g_logchain_first, *g_logchain_last;
509static pthread_mutex_t g_lognets_list_mutex = PTHREAD_MUTEX_INITIALIZER;
510
511void loglist_add_network(const ot_net *net) {
512 pthread_mutex_lock(&g_lognets_list_mutex);
513 accesslist_set_value_for_net(net, &g_lognets_list, NULL, sizeof(ot_net));
514 pthread_mutex_unlock(&g_lognets_list_mutex);
515}
516
517void loglist_reset(void) {
518 pthread_mutex_lock(&g_lognets_list_mutex);
519 free(g_lognets_list.data);
520 g_lognets_list.data = 0;
521 g_lognets_list.size = g_lognets_list.space = 0;
522 pthread_mutex_unlock(&g_lognets_list_mutex);
523}
524
525int loglist_check_address(const ot_ip6 address) {
526 int result;
527 pthread_mutex_lock(&g_lognets_list_mutex);
528 result = (NULL != accesslist_get_value_for_net(address, &g_lognets_list, sizeof(ot_net)));
529 pthread_mutex_unlock(&g_lognets_list_mutex);
530 return result;
531}
532#endif
533
534#ifdef WANT_IP_FROM_PROXY 506#ifdef WANT_IP_FROM_PROXY
535typedef struct { 507typedef struct {
536 ot_net *proxy; 508 ot_net *proxy;
diff --git a/ot_accesslist.h b/ot_accesslist.h
index 9c39a7a..ca0e126 100644
--- a/ot_accesslist.h
+++ b/ot_accesslist.h
@@ -66,22 +66,6 @@ int proxylist_add_network(const ot_net *proxy, const ot_net *net);
66int proxylist_check_network(const ot_ip6 *proxy, const ot_ip6 address /* can be NULL to only check proxy */); 66int proxylist_check_network(const ot_ip6 *proxy, const ot_ip6 address /* can be NULL to only check proxy */);
67#endif 67#endif
68 68
69#ifdef WANT_FULLLOG_NETWORKS
70typedef struct ot_log ot_log;
71struct ot_log {
72 ot_ip6 ip;
73 uint8_t *data;
74 size_t size;
75 ot_time time;
76 ot_log *next;
77};
78extern ot_log *g_logchain_first, *g_logchain_last;
79
80void loglist_add_network(const ot_net *net);
81void loglist_reset(void);
82int loglist_check_address(const ot_ip6 address);
83#endif
84
85typedef enum { 69typedef enum {
86 OT_PERMISSION_MAY_FULLSCRAPE = 0x1, 70 OT_PERMISSION_MAY_FULLSCRAPE = 0x1,
87 OT_PERMISSION_MAY_STAT = 0x2, 71 OT_PERMISSION_MAY_STAT = 0x2,
diff --git a/ot_http.c b/ot_http.c
index b0e1de3..980e256 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -292,7 +292,6 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c
292 {"version", TASK_STATS_VERSION}, 292 {"version", TASK_STATS_VERSION},
293 {"everything", TASK_STATS_EVERYTHING}, 293 {"everything", TASK_STATS_EVERYTHING},
294 {"statedump", TASK_FULLSCRAPE_TRACKERSTATE}, 294 {"statedump", TASK_FULLSCRAPE_TRACKERSTATE},
295 {"fulllog", TASK_STATS_FULLLOG},
296 {"woodpeckers", TASK_STATS_WOODPECKERS}, 295 {"woodpeckers", TASK_STATS_WOODPECKERS},
297#ifdef WANT_LOG_NUMWANT 296#ifdef WANT_LOG_NUMWANT
298 {"numwants", TASK_STATS_NUMWANTS}, 297 {"numwants", TASK_STATS_NUMWANTS},
@@ -559,10 +558,7 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event",
559#ifdef WANT_IP_FROM_QUERY_STRING 558#ifdef WANT_IP_FROM_QUERY_STRING
560 {"ip", 7}, 559 {"ip", 7},
561#endif 560#endif
562#ifdef WANT_FULLLOG_NETWORKS 561 {"peer_id", 8}, {NULL, -3}};
563 {"lognet", 8},
564#endif
565 {"peer_id", 9}, {NULL, -3}};
566static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; 562static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}};
567 563
568/* For the replies that are one fixed string and nothing else, where the only 564/* For the replies that are one fixed string and nothing else, where the only
@@ -687,43 +683,7 @@ static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct
687 OT_SETIP(&ws->peer, tmp_buf1); 683 OT_SETIP(&ws->peer, tmp_buf1);
688 } break; 684 } break;
689#endif 685#endif
690#ifdef WANT_FULLLOG_NETWORKS 686 case 8: /* matched "peer_id" */
691 case 8: /* matched "lognet" */
692 {
693 // if( accesslist_is_blessed( cookie->ip, OT_PERMISSION_MAY_STAT ) ) {
694 char *tmp_buf = ws->reply;
695 ot_net net;
696 uint64_t value;
697 signed short parsed, bits;
698
699 len = urlencoded_parse(&read_ptr, tmp_buf, SCAN_SEARCHPATH_VALUE);
700 tmp_buf[len] = 0;
701 if (len <= 0)
702 HTTPERROR_400_PARAM;
703 if (*tmp_buf == '-') {
704 loglist_reset();
705 return ws->reply_size = reply_literal(ws, "Successfully removed.\n");
706 }
707 parsed = ip_parse(tmp_buf, net.address);
708 if (!parsed)
709 HTTPERROR_400_PARAM;
710 if (tmp_buf[parsed++] != '/')
711 bits = 128;
712 else {
713 parsed = scan_uint(tmp_buf + parsed, &value, 128);
714 if (!parsed)
715 HTTPERROR_400_PARAM;
716 bits = (signed short)value;
717 if (ip_is_v4mapped(net.address))
718 bits += 96;
719 }
720 net.bits = bits;
721 loglist_add_network(&net);
722 return ws->reply_size = reply_literal(ws, "Successfully added.\n");
723 //}
724 } break;
725#endif
726 case 9: /* matched "peer_id" */
727 /* ignore this, when we have less than 20 bytes */ 687 /* ignore this, when we have less than 20 bytes */
728 if (urlencoded_parse(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20) 688 if (urlencoded_parse(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20)
729 HTTPERROR_400_PARAM; 689 HTTPERROR_400_PARAM;
@@ -757,30 +717,6 @@ ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) {
757 ssize_t reply_off, len; 717 ssize_t reply_off, len;
758 char *read_ptr = ws->request, *write_ptr; 718 char *read_ptr = ws->request, *write_ptr;
759 719
760#ifdef WANT_FULLLOG_NETWORKS
761 struct http_data *cookie = fdstate_cookie(sock);
762 if (loglist_check_address(cookie->ip)) {
763 ot_log *log = malloc(sizeof(ot_log));
764 if (log) {
765 log->size = ws->request_size;
766 log->data = malloc(ws->request_size);
767 log->next = 0;
768 log->time = time_now_seconds();
769 memcpy(log->ip, cookie->ip, sizeof(ot_ip6));
770 if (log->data) {
771 memcpy(log->data, ws->request, ws->request_size);
772 if (!g_logchain_first)
773 g_logchain_first = g_logchain_last = log;
774 else {
775 g_logchain_last->next = log;
776 g_logchain_last = log;
777 }
778 } else
779 free(log);
780 }
781 }
782#endif
783
784#ifdef _DEBUG_HTTPERROR 720#ifdef _DEBUG_HTTPERROR
785 reply_off = ws->request_size; 721 reply_off = ws->request_size;
786 if (ws->request_size >= G_DEBUGBUF_SIZE) 722 if (ws->request_size >= G_DEBUGBUF_SIZE)
diff --git a/ot_stats.c b/ot_stats.c
index d38355a..eb046a0 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -117,10 +117,6 @@ union stats_network_node {
117 stats_network_node *children[STATS_NETWORK_NODE_COUNT]; 117 stats_network_node *children[STATS_NETWORK_NODE_COUNT];
118}; 118};
119 119
120#ifdef WANT_LOG_NETWORKS
121static stats_network_node *stats_network_counters_root;
122#endif
123
124static int stat_increase_network_count(stats_network_node **pnode, int depth, uintptr_t ip) { 120static int stat_increase_network_count(stats_network_node **pnode, int depth, uintptr_t ip) {
125 int foo = __LDR(ip, depth); 121 int foo = __LDR(ip, depth);
126 stats_network_node *node; 122 stats_network_node *node;
@@ -504,36 +500,6 @@ static void stats_return_numwants(char **reply, const char *reply_en
504} 500}
505#endif 501#endif
506 502
507#ifdef WANT_FULLLOG_NETWORKS
508static void stats_return_fulllog(size_t *iovec_entries, struct iovec **iovector, char *r) {
509 ot_log *loglist = g_logchain_first, *llnext;
510 char *re = r + OT_STATS_TMPSIZE;
511
512 g_logchain_first = g_logchain_last = 0;
513
514 while (loglist) {
515 if (r + (loglist->size + 64) >= re) {
516 r = iovec_next_chunk(iovec_entries, iovector, r, 32 * OT_STATS_TMPSIZE);
517 if (!r)
518 return;
519 re = r + 32 * OT_STATS_TMPSIZE;
520 }
521 char ip_readable[64];
522
523 ip_readable[ip_format(ip_readable, loglist->ip)] = 0;
524 fmt_append(&r, re, "%08ld: %s\n", loglist->time, ip_readable);
525 fmt_bytes(&r, re, loglist->data, loglist->size);
526 fmt_append(&r, re, "\n*\n\n");
527
528 llnext = loglist->next;
529 free(loglist->data);
530 free(loglist);
531 loglist = llnext;
532 }
533 iovec_trim_last(iovec_entries, iovector, r);
534}
535#endif
536
537static void stats_return_everything(char **reply, const char *reply_end) { 503static void stats_return_everything(char **reply, const char *reply_end) {
538 unsigned long long total[OT_COUNTER_COUNT]; 504 unsigned long long total[OT_COUNTER_COUNT];
539 505
@@ -671,11 +637,6 @@ static void stats_make(size_t *iovec_entries, struct iovec **iovector, ot_taskty
671 stats_return_woodpeckers(&r, r_end, 128); 637 stats_return_woodpeckers(&r, r_end, 128);
672 break; 638 break;
673#endif 639#endif
674#ifdef WANT_FULLLOG_NETWORKS
675 case TASK_STATS_FULLLOG:
676 stats_return_fulllog(iovec_entries, iovector, r);
677 return;
678#endif
679 default: 640 default:
680 iovec_free(iovec_entries, iovector); 641 iovec_free(iovec_entries, iovector);
681 return; 642 return;
@@ -693,9 +654,6 @@ void stats_issue_event(struct ot_workstruct *ws, ot_status_event event, PROTO_FL
693 COUNT(OT_COUNTER_TCP_CONNECTIONS, 1); 654 COUNT(OT_COUNTER_TCP_CONNECTIONS, 1);
694 else 655 else
695 COUNT(OT_COUNTER_UDP_CONNECTIONS, 1); 656 COUNT(OT_COUNTER_UDP_CONNECTIONS, 1);
696#ifdef WANT_LOG_NETWORKS
697 stat_increase_network_count(&stats_network_counters_root, 0, event_data);
698#endif
699 break; 657 break;
700 case EVENT_ANNOUNCE: 658 case EVENT_ANNOUNCE:
701 if (proto == FLAG_TCP) 659 if (proto == FLAG_TCP)
diff --git a/ot_workqueue.h b/ot_workqueue.h
index f99a7b5..8fa80d0 100644
--- a/ot_workqueue.h
+++ b/ot_workqueue.h
@@ -36,7 +36,6 @@ typedef enum {
36 TASK_STATS_TOP10 = 0x0104, 36 TASK_STATS_TOP10 = 0x0104,
37 TASK_STATS_TOP100 = 0x0105, 37 TASK_STATS_TOP100 = 0x0105,
38 TASK_STATS_EVERYTHING = 0x0106, 38 TASK_STATS_EVERYTHING = 0x0106,
39 TASK_STATS_FULLLOG = 0x0107,
40 TASK_STATS_WOODPECKERS = 0x0108, 39 TASK_STATS_WOODPECKERS = 0x0108,
41 40
42 TASK_FULLSCRAPE = 0x0200, /* Default mode */ 41 TASK_FULLSCRAPE = 0x0200, /* Default mode */
diff --git a/tests/integration/test_stats.py b/tests/integration/test_stats.py
index 820b917..46e9c64 100644
--- a/tests/integration/test_stats.py
+++ b/tests/integration/test_stats.py
@@ -15,8 +15,8 @@ import xml.etree.ElementTree
15from harness import TrackerTestCase 15from harness import TrackerTestCase
16 16
17# The modes a default build answers. "tpbs" and "statedump" are full scrapes 17# The modes a default build answers. "tpbs" and "statedump" are full scrapes
18# and belong to test_fullscrape; "fulllog" and "woodpeckers" sit behind 18# and belong to test_fullscrape; "woodpeckers" sits behind a
19# feature flags this build does not set. 19# feature flag this build does not set.
20MRTG_MODES = ["peer", "conn", "scrp", "udp4", "tcp4", "torr", "fscr", "completed", "syncs"] 20MRTG_MODES = ["peer", "conn", "scrp", "udp4", "tcp4", "torr", "fscr", "completed", "syncs"]
21TEXT_MODES = ["herr", "s24s", "top10", "top100", "renew", "version"] 21TEXT_MODES = ["herr", "s24s", "top10", "top100", "renew", "version"]
22 22
diff --git a/trackerlogic.h b/trackerlogic.h
index 53edabd..39afece 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -256,10 +256,6 @@ void workstruct_deinit(struct ot_workstruct *ws);
256#define WANT_SYNC_PARAM(param) 256#define WANT_SYNC_PARAM(param)
257#endif 257#endif
258 258
259#ifdef WANT_LOG_NETWORKS
260#error Live logging networks disabled at the moment.
261#endif
262
263void trackerlogic_init(void); 259void trackerlogic_init(void);
264void trackerlogic_deinit(void); 260void trackerlogic_deinit(void);
265void exerr(const char *message); 261void exerr(const char *message);