From a0569d2d3cdca5d6ed78e0df77b08ccbbec52570 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 02:22:56 +0100 Subject: Report the version, event machanism and feature flags with -v --- ot_stats.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'ot_stats.c') diff --git a/ot_stats.c b/ot_stats.c index a9f12cc..5edbe0a 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -19,6 +19,7 @@ /* Opentracker */ #include "ot_accesslist.h" +#include "ot_event.h" #include "ot_hex.h" #include "ot_iovec.h" #include "ot_ip.h" @@ -546,6 +547,92 @@ static void stats_return_everything(char **reply, const char *reply_end) { fmt_append(reply, reply_end, ""); } +/* The names as the Makefile spells them, so that what a binary reports maps + straight back onto the FEATURES lines it was built from */ +static const char *const build_features[] = { +#ifdef WANT_V4_ONLY + "WANT_V4_ONLY", +#endif +#ifdef WANT_ACCESSLIST_BLACK + "WANT_ACCESSLIST_BLACK", +#endif +#ifdef WANT_ACCESSLIST_WHITE + "WANT_ACCESSLIST_WHITE", +#endif +#ifdef WANT_DYNAMIC_ACCESSLIST + "WANT_DYNAMIC_ACCESSLIST", +#endif +#ifdef WANT_SYNC_LIVE + "WANT_SYNC_LIVE", +#endif +#ifdef WANT_IP_FROM_QUERY_STRING + "WANT_IP_FROM_QUERY_STRING", +#endif +#ifdef WANT_IP_FROM_PROXY + "WANT_IP_FROM_PROXY", +#endif +#ifdef WANT_COMPRESSION_GZIP + "WANT_COMPRESSION_GZIP", +#endif +#ifdef WANT_COMPRESSION_GZIP_ALWAYS + "WANT_COMPRESSION_GZIP_ALWAYS", +#endif +#ifdef WANT_COMPRESSION_ZSTD + "WANT_COMPRESSION_ZSTD", +#endif +#ifdef WANT_COMPRESSION_ZSTD_ALWAYS + "WANT_COMPRESSION_ZSTD_ALWAYS", +#endif +#ifdef WANT_FULLSCRAPE + "WANT_FULLSCRAPE", +#endif +#ifdef WANT_MODEST_FULLSCRAPES + "WANT_MODEST_FULLSCRAPES", +#endif +#ifdef WANT_KEEPALIVE + "WANT_KEEPALIVE", +#endif +#ifdef WANT_RESTRICT_STATS + "WANT_RESTRICT_STATS", +#endif +#ifdef WANT_LOG_NUMWANT + "WANT_LOG_NUMWANT", +#endif +#ifdef WANT_SPOT_WOODPECKER + "WANT_SPOT_WOODPECKER", +#endif +#ifdef WANT_SYSLOGS + "WANT_SYSLOGS", +#endif +#ifdef WANT_DEV_RANDOM + "WANT_DEV_RANDOM", +#endif +#ifdef WANT_INSECURE_RANDOM_FALLBACK + "WANT_INSECURE_RANDOM_FALLBACK", +#endif +#ifdef _DEBUG + "_DEBUG", +#endif +#ifdef _DEBUG_HTTPERROR + "_DEBUG_HTTPERROR", +#endif +#ifdef _DEBUG_RANDOMTORRENTS + "_DEBUG_RANDOMTORRENTS", +#endif + NULL}; + +void stats_return_tracker_features(char **reply, const char *reply_end) { + size_t i; + + fmt_append(reply, reply_end, "events: %s\n", event_mechanism()); + fmt_append(reply, reply_end, "features:"); + for (i = 0; build_features[i]; ++i) + fmt_append(reply, reply_end, " %s", build_features[i]); + if (!build_features[0]) + fmt_append(reply, reply_end, " none"); + fmt_append(reply, reply_end, "\n"); +} + void stats_return_tracker_version(char **reply, const char *reply_end) { fmt_append(reply, reply_end, "opentracker %s", OT_VERSION); /* Empty when the build had no git to ask, which is what a release tarball -- cgit v1.3