diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 02:22:56 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 02:22:56 +0100 |
| commit | a0569d2d3cdca5d6ed78e0df77b08ccbbec52570 (patch) | |
| tree | 4f9367f218f69f8864c81d95668ac27758d8d3dd | |
| parent | 6de11792013cd087897fd7c2a7519fd26211b105 (diff) | |
Report the version, event machanism and feature flags with -v
| -rw-r--r-- | man1/opentracker.1 | 4 | ||||
| -rw-r--r-- | ot_config.c | 2 | ||||
| -rw-r--r-- | ot_stats.c | 87 | ||||
| -rw-r--r-- | ot_stats.h | 1 |
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 |
| 20 | is a bittorrent tracker that implements announce and scrape actions over the | 21 | is a bittorrent tracker that implements announce and scrape actions over the |
| @@ -85,6 +86,9 @@ has been compiled with the | |||
| 85 | or | 86 | or |
| 86 | .Br WANT_ACCESSLIST_WHITE | 87 | .Br WANT_ACCESSLIST_WHITE |
| 87 | options, this option sets the location of the accesslist. | 88 | options, this option sets the location of the accesslist. |
| 89 | .It Fl v | ||
| 90 | Report the version, the event mechanism in use and the feature flags this | ||
| 91 | binary was built with. | ||
| 88 | .El | 92 | .El |
| 89 | .Sh EXAMPLES | 93 | .Sh EXAMPLES |
| 90 | Start | 94 | Start |
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); |
| @@ -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 */ | ||
| 552 | static 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 | |||
| 624 | void 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 | |||
| 549 | void stats_return_tracker_version(char **reply, const char *reply_end) { | 636 | void 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 |
| @@ -35,6 +35,7 @@ void stats_deliver(int64_t sock, int tasktype); | |||
| 35 | void stats_cleanup(void); | 35 | void stats_cleanup(void); |
| 36 | void return_stats_for_tracker(char **reply, const char *reply_end, int mode, int format); | 36 | void return_stats_for_tracker(char **reply, const char *reply_end, int mode, int format); |
| 37 | void stats_return_tracker_version(char **reply, const char *reply_end); | 37 | void stats_return_tracker_version(char **reply, const char *reply_end); |
| 38 | void stats_return_tracker_features(char **reply, const char *reply_end); | ||
| 38 | void stats_init(void); | 39 | void stats_init(void); |
| 39 | void stats_deinit(void); | 40 | void stats_deinit(void); |
| 40 | 41 | ||
