diff options
author | Alexander Færøy <ahf@torproject.org> | 2021-04-12 18:36:05 +0000 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-04-13 15:11:03 -0400 |
commit | 705ea32c6e832ab2f063dc9802a03f53e4371b9a (patch) | |
tree | f5d16b823e6790c194118f496fc661608f82d238 /src/feature/stats | |
parent | 1b48a28a7476d8c29cb505ad53daa3c4fe275500 (diff) | |
download | tor-705ea32c6e832ab2f063dc9802a03f53e4371b9a.tar.gz tor-705ea32c6e832ab2f063dc9802a03f53e4371b9a.zip |
relay: Move "overload-general" from extra-info to server descriptor.
Fixes #40364
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/stats')
-rw-r--r-- | src/feature/stats/rephist.c | 27 | ||||
-rw-r--r-- | src/feature/stats/rephist.h | 1 |
2 files changed, 20 insertions, 8 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c index 4ad5d46b0c..e25c01331d 100644 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@ -221,23 +221,34 @@ overload_happened_recently(time_t overload_time, int n_hours) /* The current version of the overload stats version */ #define OVERLOAD_STATS_VERSION 1 -/** Returns an allocated string for extra-info documents for publishing - * overload statistics. */ +/** Returns an allocated string for server descriptor for publising information + * on whether we are overloaded or not. */ char * -rep_hist_get_overload_stats_lines(void) +rep_hist_get_overload_general_line(void) { char *result = NULL; - smartlist_t *chunks = smartlist_new(); char tbuf[ISO_TIME_LEN+1]; - /* First encode the general overload */ + /* Encode the general overload */ if (overload_happened_recently(overload_stats.overload_general_time, 72)) { format_iso_time(tbuf, overload_stats.overload_general_time); - smartlist_add_asprintf(chunks, "overload-general %d %s\n", - OVERLOAD_STATS_VERSION, tbuf); + tor_asprintf(&result, "overload-general %d %s\n", + OVERLOAD_STATS_VERSION, tbuf); } - /* Now do bandwidth-related overloads */ + return result; +} + +/** Returns an allocated string for extra-info documents for publishing + * overload statistics. */ +char * +rep_hist_get_overload_stats_lines(void) +{ + char *result = NULL; + smartlist_t *chunks = smartlist_new(); + char tbuf[ISO_TIME_LEN+1]; + + /* Add bandwidth-related overloads */ if (overload_happened_recently(overload_stats.overload_ratelimits_time,24)) { const or_options_t *options = get_options(); format_iso_time(tbuf, overload_stats.overload_ratelimits_time); diff --git a/src/feature/stats/rephist.h b/src/feature/stats/rephist.h index 5aaf5c9255..d4a2f301cf 100644 --- a/src/feature/stats/rephist.h +++ b/src/feature/stats/rephist.h @@ -156,6 +156,7 @@ typedef enum { } overload_type_t; void rep_hist_note_overload(overload_type_t overload); +char *rep_hist_get_overload_general_line(void); char *rep_hist_get_overload_stats_lines(void); #ifdef TOR_UNIT_TESTS |