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 /ot_stats.c | |
| parent | 6de11792013cd087897fd7c2a7519fd26211b105 (diff) | |
Report the version, event machanism and feature flags with -v
Diffstat (limited to 'ot_stats.c')
| -rw-r--r-- | ot_stats.c | 87 |
1 files changed, 87 insertions, 0 deletions
| @@ -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 |
