From 451947b7bed5ba6c9c925ceb10df39c42a330614 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 1 Nov 2026 21:38:11 +0100 Subject: Live logging networks was defunc for a while, does not work with v6, so we remove it --- Makefile | 2 -- ot_accesslist.c | 28 ----------------- ot_accesslist.h | 16 ---------- ot_http.c | 68 ++--------------------------------------- ot_stats.c | 42 ------------------------- ot_workqueue.h | 1 - tests/integration/test_stats.py | 4 +-- trackerlogic.h | 4 --- 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 # in Makefile.zstd #include Makefile.zstd -#FEATURES+=-DWANT_LOG_NETWORKS #FEATURES+=-DWANT_RESTRICT_STATS #FEATURES+=-DWANT_IP_FROM_PROXY -#FEATURES+=-DWANT_FULLLOG_NETWORKS #FEATURES+=-DWANT_LOG_NUMWANT #FEATURES+=-DWANT_MODEST_FULLSCRAPES #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 return (void *)net; } -#ifdef WANT_FULLLOG_NETWORKS -static ot_vector g_lognets_list; -ot_log *g_logchain_first, *g_logchain_last; -static pthread_mutex_t g_lognets_list_mutex = PTHREAD_MUTEX_INITIALIZER; - -void loglist_add_network(const ot_net *net) { - pthread_mutex_lock(&g_lognets_list_mutex); - accesslist_set_value_for_net(net, &g_lognets_list, NULL, sizeof(ot_net)); - pthread_mutex_unlock(&g_lognets_list_mutex); -} - -void loglist_reset(void) { - pthread_mutex_lock(&g_lognets_list_mutex); - free(g_lognets_list.data); - g_lognets_list.data = 0; - g_lognets_list.size = g_lognets_list.space = 0; - pthread_mutex_unlock(&g_lognets_list_mutex); -} - -int loglist_check_address(const ot_ip6 address) { - int result; - pthread_mutex_lock(&g_lognets_list_mutex); - result = (NULL != accesslist_get_value_for_net(address, &g_lognets_list, sizeof(ot_net))); - pthread_mutex_unlock(&g_lognets_list_mutex); - return result; -} -#endif - #ifdef WANT_IP_FROM_PROXY typedef struct { 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); int proxylist_check_network(const ot_ip6 *proxy, const ot_ip6 address /* can be NULL to only check proxy */); #endif -#ifdef WANT_FULLLOG_NETWORKS -typedef struct ot_log ot_log; -struct ot_log { - ot_ip6 ip; - uint8_t *data; - size_t size; - ot_time time; - ot_log *next; -}; -extern ot_log *g_logchain_first, *g_logchain_last; - -void loglist_add_network(const ot_net *net); -void loglist_reset(void); -int loglist_check_address(const ot_ip6 address); -#endif - typedef enum { OT_PERMISSION_MAY_FULLSCRAPE = 0x1, 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 {"version", TASK_STATS_VERSION}, {"everything", TASK_STATS_EVERYTHING}, {"statedump", TASK_FULLSCRAPE_TRACKERSTATE}, - {"fulllog", TASK_STATS_FULLLOG}, {"woodpeckers", TASK_STATS_WOODPECKERS}, #ifdef WANT_LOG_NUMWANT {"numwants", TASK_STATS_NUMWANTS}, @@ -559,10 +558,7 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event", #ifdef WANT_IP_FROM_QUERY_STRING {"ip", 7}, #endif -#ifdef WANT_FULLLOG_NETWORKS - {"lognet", 8}, -#endif - {"peer_id", 9}, {NULL, -3}}; + {"peer_id", 8}, {NULL, -3}}; static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; /* 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 OT_SETIP(&ws->peer, tmp_buf1); } break; #endif -#ifdef WANT_FULLLOG_NETWORKS - case 8: /* matched "lognet" */ - { - // if( accesslist_is_blessed( cookie->ip, OT_PERMISSION_MAY_STAT ) ) { - char *tmp_buf = ws->reply; - ot_net net; - uint64_t value; - signed short parsed, bits; - - len = urlencoded_parse(&read_ptr, tmp_buf, SCAN_SEARCHPATH_VALUE); - tmp_buf[len] = 0; - if (len <= 0) - HTTPERROR_400_PARAM; - if (*tmp_buf == '-') { - loglist_reset(); - return ws->reply_size = reply_literal(ws, "Successfully removed.\n"); - } - parsed = ip_parse(tmp_buf, net.address); - if (!parsed) - HTTPERROR_400_PARAM; - if (tmp_buf[parsed++] != '/') - bits = 128; - else { - parsed = scan_uint(tmp_buf + parsed, &value, 128); - if (!parsed) - HTTPERROR_400_PARAM; - bits = (signed short)value; - if (ip_is_v4mapped(net.address)) - bits += 96; - } - net.bits = bits; - loglist_add_network(&net); - return ws->reply_size = reply_literal(ws, "Successfully added.\n"); - //} - } break; -#endif - case 9: /* matched "peer_id" */ + case 8: /* matched "peer_id" */ /* ignore this, when we have less than 20 bytes */ if (urlencoded_parse(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20) HTTPERROR_400_PARAM; @@ -757,30 +717,6 @@ ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) { ssize_t reply_off, len; char *read_ptr = ws->request, *write_ptr; -#ifdef WANT_FULLLOG_NETWORKS - struct http_data *cookie = fdstate_cookie(sock); - if (loglist_check_address(cookie->ip)) { - ot_log *log = malloc(sizeof(ot_log)); - if (log) { - log->size = ws->request_size; - log->data = malloc(ws->request_size); - log->next = 0; - log->time = time_now_seconds(); - memcpy(log->ip, cookie->ip, sizeof(ot_ip6)); - if (log->data) { - memcpy(log->data, ws->request, ws->request_size); - if (!g_logchain_first) - g_logchain_first = g_logchain_last = log; - else { - g_logchain_last->next = log; - g_logchain_last = log; - } - } else - free(log); - } - } -#endif - #ifdef _DEBUG_HTTPERROR reply_off = ws->request_size; 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 { stats_network_node *children[STATS_NETWORK_NODE_COUNT]; }; -#ifdef WANT_LOG_NETWORKS -static stats_network_node *stats_network_counters_root; -#endif - static int stat_increase_network_count(stats_network_node **pnode, int depth, uintptr_t ip) { int foo = __LDR(ip, depth); stats_network_node *node; @@ -504,36 +500,6 @@ static void stats_return_numwants(char **reply, const char *reply_en } #endif -#ifdef WANT_FULLLOG_NETWORKS -static void stats_return_fulllog(size_t *iovec_entries, struct iovec **iovector, char *r) { - ot_log *loglist = g_logchain_first, *llnext; - char *re = r + OT_STATS_TMPSIZE; - - g_logchain_first = g_logchain_last = 0; - - while (loglist) { - if (r + (loglist->size + 64) >= re) { - r = iovec_next_chunk(iovec_entries, iovector, r, 32 * OT_STATS_TMPSIZE); - if (!r) - return; - re = r + 32 * OT_STATS_TMPSIZE; - } - char ip_readable[64]; - - ip_readable[ip_format(ip_readable, loglist->ip)] = 0; - fmt_append(&r, re, "%08ld: %s\n", loglist->time, ip_readable); - fmt_bytes(&r, re, loglist->data, loglist->size); - fmt_append(&r, re, "\n*\n\n"); - - llnext = loglist->next; - free(loglist->data); - free(loglist); - loglist = llnext; - } - iovec_trim_last(iovec_entries, iovector, r); -} -#endif - static void stats_return_everything(char **reply, const char *reply_end) { unsigned long long total[OT_COUNTER_COUNT]; @@ -670,11 +636,6 @@ static void stats_make(size_t *iovec_entries, struct iovec **iovector, ot_taskty case TASK_STATS_WOODPECKERS: stats_return_woodpeckers(&r, r_end, 128); break; -#endif -#ifdef WANT_FULLLOG_NETWORKS - case TASK_STATS_FULLLOG: - stats_return_fulllog(iovec_entries, iovector, r); - return; #endif default: iovec_free(iovec_entries, iovector); @@ -693,9 +654,6 @@ void stats_issue_event(struct ot_workstruct *ws, ot_status_event event, PROTO_FL COUNT(OT_COUNTER_TCP_CONNECTIONS, 1); else COUNT(OT_COUNTER_UDP_CONNECTIONS, 1); -#ifdef WANT_LOG_NETWORKS - stat_increase_network_count(&stats_network_counters_root, 0, event_data); -#endif break; case EVENT_ANNOUNCE: 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 { TASK_STATS_TOP10 = 0x0104, TASK_STATS_TOP100 = 0x0105, TASK_STATS_EVERYTHING = 0x0106, - TASK_STATS_FULLLOG = 0x0107, TASK_STATS_WOODPECKERS = 0x0108, 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 from harness import TrackerTestCase # The modes a default build answers. "tpbs" and "statedump" are full scrapes -# and belong to test_fullscrape; "fulllog" and "woodpeckers" sit behind -# feature flags this build does not set. +# and belong to test_fullscrape; "woodpeckers" sits behind a +# feature flag this build does not set. MRTG_MODES = ["peer", "conn", "scrp", "udp4", "tcp4", "torr", "fscr", "completed", "syncs"] TEXT_MODES = ["herr", "s24s", "top10", "top100", "renew", "version"] 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); #define WANT_SYNC_PARAM(param) #endif -#ifdef WANT_LOG_NETWORKS -#error Live logging networks disabled at the moment. -#endif - void trackerlogic_init(void); void trackerlogic_deinit(void); void exerr(const char *message); -- cgit v1.3