From 14f1f19dab3f41b5bcaeb40f63964c57eb1e25f2 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 5 Nov 2026 14:57:13 +0100 Subject: Step 2 of the WANT_RESTRICT_FULLSCRAPE feature (fixing a bug along the way) --- src/ot_config.c | 2 +- src/ot_http.c | 7 +++++++ src/ot_stats.c | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ot_config.c b/src/ot_config.c index dfaef0d..9c5e8f0 100644 --- a/src/ot_config.c +++ b/src/ot_config.c @@ -276,7 +276,7 @@ static int parse_configfile(char *config_filename) { FILE *config_file_handle; char inbuf[512]; ot_ip6 tmpip; -#if defined(WANT_RESTRICT_STATS) || defined(WANT_IP_FROM_PROXY) || defined(WANT_SYNC_LIVE) +#if defined(WANT_RESTRICT_STATS) || defined(WANT_RESTRICT_FULLSCRAPE) || defined(WANT_IP_FROM_PROXY) || defined(WANT_SYNC_LIVE) ot_net tmpnet; #endif int bound = 0; diff --git a/src/ot_http.c b/src/ot_http.c index d2dad67..cc11366 100644 --- a/src/ot_http.c +++ b/src/ot_http.c @@ -342,6 +342,10 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c } if (mode == TASK_STATS_TPB) { +#ifdef WANT_RESTRICT_FULLSCRAPE + if (!accesslist_is_blessed(cookie->ip, OT_PERMISSION_MAY_FULLSCRAPE)) + HTTPERROR_403_IP; +#endif #ifdef WANT_COMPRESSION_GZIP ws->request[ws->request_size - 1] = 0; #ifndef WANT_COMPRESSION_GZIP_ALWAYS @@ -402,6 +406,9 @@ static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct * struct http_data *cookie = fdstate_cookie(sock); int format = 0; + if (!cookie) + HTTPERROR_500; + #ifdef WANT_RESTRICT_FULLSCRAPE if (!accesslist_is_blessed(cookie->ip, OT_PERMISSION_MAY_FULLSCRAPE)) HTTPERROR_403_IP; diff --git a/src/ot_stats.c b/src/ot_stats.c index 7b5b1b9..d395275 100644 --- a/src/ot_stats.c +++ b/src/ot_stats.c @@ -588,6 +588,9 @@ static const char *const build_features[] = { #ifdef WANT_RESTRICT_STATS "WANT_RESTRICT_STATS", #endif +#ifdef WANT_RESTRICT_FULLSCRAPE + "WANT_RESTRICT_FULLSCRAPE", +#endif #ifdef WANT_LOG_NUMWANT "WANT_LOG_NUMWANT", #endif -- cgit v1.3