summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man1/opentracker.14
-rw-r--r--ot_config.c2
-rw-r--r--ot_stats.c87
-rw-r--r--ot_stats.h1
4 files changed, 94 insertions, 0 deletions
diff --git a/man1/opentracker.1 b/man1/opentracker.1
index 0103ebe..489a54c 100644
--- a/man1/opentracker.1
+++ b/man1/opentracker.1
@@ -15,6 +15,7 @@
15.Op Fl d Ar chdir 15.Op Fl d Ar chdir
16.Op Fl u Ar user 16.Op Fl u Ar user
17.Op Fl w| Fl b accesslist 17.Op Fl w| Fl b accesslist
18.Op Fl v
18.Sh DESCRIPTION 19.Sh DESCRIPTION
19.Nm 20.Nm
20is a bittorrent tracker that implements announce and scrape actions over the 21is a bittorrent tracker that implements announce and scrape actions over the
@@ -85,6 +86,9 @@ has been compiled with the
85or 86or
86.Br WANT_ACCESSLIST_WHITE 87.Br WANT_ACCESSLIST_WHITE
87options, this option sets the location of the accesslist. 88options, this option sets the location of the accesslist.
89.It Fl v
90Report the version, the event mechanism in use and the feature flags this
91binary was built with.
88.El 92.El
89.Sh EXAMPLES 93.Sh EXAMPLES
90Start 94Start
diff --git a/ot_config.c b/ot_config.c
index 272acf1..5da6642 100644
--- a/ot_config.c
+++ b/ot_config.c
@@ -432,6 +432,7 @@ static void help(char *name) {
432 HELPLINE("-d dir", "specify directory to try to chroot to (default: \".\")"); 432 HELPLINE("-d dir", "specify directory to try to chroot to (default: \".\")");
433 HELPLINE("-u user", "specify user under whose privileges opentracker should run (default: \"nobody\")"); 433 HELPLINE("-u user", "specify user under whose privileges opentracker should run (default: \"nobody\")");
434 HELPLINE("-A ip[/bits]", "bless an ip address or net as admin address (e.g. to allow syncs from this address)"); 434 HELPLINE("-A ip[/bits]", "bless an ip address or net as admin address (e.g. to allow syncs from this address)");
435 HELPLINE("-v", "report version, event mechanism and the feature flags opentracker was built with");
435#ifdef WANT_ACCESSLIST_BLACK 436#ifdef WANT_ACCESSLIST_BLACK
436 HELPLINE("-b file", "specify blacklist file."); 437 HELPLINE("-b file", "specify blacklist file.");
437#elif defined(WANT_ACCESSLIST_WHITE) 438#elif defined(WANT_ACCESSLIST_WHITE)
@@ -566,6 +567,7 @@ void config_parse(int argc, char **argv) {
566 char *cursor = buffer; 567 char *cursor = buffer;
567 568
568 stats_return_tracker_version(&cursor, buffer + sizeof(buffer) - 1); 569 stats_return_tracker_version(&cursor, buffer + sizeof(buffer) - 1);
570 stats_return_tracker_features(&cursor, buffer + sizeof(buffer) - 1);
569 *cursor = 0; 571 *cursor = 0;
570 fputs(buffer, stderr); 572 fputs(buffer, stderr);
571 exit(0); 573 exit(0);
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 @@
19 19
20/* Opentracker */ 20/* Opentracker */
21#include "ot_accesslist.h" 21#include "ot_accesslist.h"
22#include "ot_event.h"
22#include "ot_hex.h" 23#include "ot_hex.h"
23#include "ot_iovec.h" 24#include "ot_iovec.h"
24#include "ot_ip.h" 25#include "ot_ip.h"
@@ -546,6 +547,92 @@ static void stats_return_everything(char **reply, const char *reply_end) {
546 fmt_append(reply, reply_end, "</stats>"); 547 fmt_append(reply, reply_end, "</stats>");
547} 548}
548 549
550/* The names as the Makefile spells them, so that what a binary reports maps
551 straight back onto the FEATURES lines it was built from */
552static const char *const build_features[] = {
553#ifdef WANT_V4_ONLY
554 "WANT_V4_ONLY",
555#endif
556#ifdef WANT_ACCESSLIST_BLACK
557 "WANT_ACCESSLIST_BLACK",
558#endif
559#ifdef WANT_ACCESSLIST_WHITE
560 "WANT_ACCESSLIST_WHITE",
561#endif
562#ifdef WANT_DYNAMIC_ACCESSLIST
563 "WANT_DYNAMIC_ACCESSLIST",
564#endif
565#ifdef WANT_SYNC_LIVE
566 "WANT_SYNC_LIVE",
567#endif
568#ifdef WANT_IP_FROM_QUERY_STRING
569 "WANT_IP_FROM_QUERY_STRING",
570#endif
571#ifdef WANT_IP_FROM_PROXY
572 "WANT_IP_FROM_PROXY",
573#endif
574#ifdef WANT_COMPRESSION_GZIP
575 "WANT_COMPRESSION_GZIP",
576#endif
577#ifdef WANT_COMPRESSION_GZIP_ALWAYS
578 "WANT_COMPRESSION_GZIP_ALWAYS",
579#endif
580#ifdef WANT_COMPRESSION_ZSTD
581 "WANT_COMPRESSION_ZSTD",
582#endif
583#ifdef WANT_COMPRESSION_ZSTD_ALWAYS
584 "WANT_COMPRESSION_ZSTD_ALWAYS",
585#endif
586#ifdef WANT_FULLSCRAPE
587 "WANT_FULLSCRAPE",
588#endif
589#ifdef WANT_MODEST_FULLSCRAPES
590 "WANT_MODEST_FULLSCRAPES",
591#endif
592#ifdef WANT_KEEPALIVE
593 "WANT_KEEPALIVE",
594#endif
595#ifdef WANT_RESTRICT_STATS
596 "WANT_RESTRICT_STATS",
597#endif
598#ifdef WANT_LOG_NUMWANT
599 "WANT_LOG_NUMWANT",
600#endif
601#ifdef WANT_SPOT_WOODPECKER
602 "WANT_SPOT_WOODPECKER",
603#endif
604#ifdef WANT_SYSLOGS
605 "WANT_SYSLOGS",
606#endif
607#ifdef WANT_DEV_RANDOM
608 "WANT_DEV_RANDOM",
609#endif
610#ifdef WANT_INSECURE_RANDOM_FALLBACK
611 "WANT_INSECURE_RANDOM_FALLBACK",
612#endif
613#ifdef _DEBUG
614 "_DEBUG",
615#endif
616#ifdef _DEBUG_HTTPERROR
617 "_DEBUG_HTTPERROR",
618#endif
619#ifdef _DEBUG_RANDOMTORRENTS
620 "_DEBUG_RANDOMTORRENTS",
621#endif
622 NULL};
623
624void stats_return_tracker_features(char **reply, const char *reply_end) {
625 size_t i;
626
627 fmt_append(reply, reply_end, "events: %s\n", event_mechanism());
628 fmt_append(reply, reply_end, "features:");
629 for (i = 0; build_features[i]; ++i)
630 fmt_append(reply, reply_end, " %s", build_features[i]);
631 if (!build_features[0])
632 fmt_append(reply, reply_end, " none");
633 fmt_append(reply, reply_end, "\n");
634}
635
549void stats_return_tracker_version(char **reply, const char *reply_end) { 636void stats_return_tracker_version(char **reply, const char *reply_end) {
550 fmt_append(reply, reply_end, "opentracker %s", OT_VERSION); 637 fmt_append(reply, reply_end, "opentracker %s", OT_VERSION);
551 /* Empty when the build had no git to ask, which is what a release tarball 638 /* Empty when the build had no git to ask, which is what a release tarball
diff --git a/ot_stats.h b/ot_stats.h
index f484765..f9a9d87 100644
--- a/ot_stats.h
+++ b/ot_stats.h
@@ -35,6 +35,7 @@ void stats_deliver(int64_t sock, int tasktype);
35void stats_cleanup(void); 35void stats_cleanup(void);
36void return_stats_for_tracker(char **reply, const char *reply_end, int mode, int format); 36void return_stats_for_tracker(char **reply, const char *reply_end, int mode, int format);
37void stats_return_tracker_version(char **reply, const char *reply_end); 37void stats_return_tracker_version(char **reply, const char *reply_end);
38void stats_return_tracker_features(char **reply, const char *reply_end);
38void stats_init(void); 39void stats_init(void);
39void stats_deinit(void); 40void stats_deinit(void);
40 41