aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2023-05-24 10:40:25 -0400
committerDavid Goulet <dgoulet@torproject.org>2023-05-24 10:40:25 -0400
commit21ec9017f60a0f7f9fc04782bc4bab6b836f0758 (patch)
tree3f7a0133220fb276c1f727b5007c52f020aeda72
parent6bf56ac301d6321b9b72c11aef73d64e0aa38c23 (diff)
parent0c634999c13bdf40843924d54fc3294136774788 (diff)
downloadtor-21ec9017f60a0f7f9fc04782bc4bab6b836f0758.tar.gz
tor-21ec9017f60a0f7f9fc04782bc4bab6b836f0758.zip
Merge branch 'tor-gitlab/mr/698'
-rw-r--r--src/feature/relay/relay_metrics.c29
-rw-r--r--src/feature/relay/relay_metrics.h2
2 files changed, 31 insertions, 0 deletions
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c
index 99204931fc..494cfb34dd 100644
--- a/src/feature/relay/relay_metrics.c
+++ b/src/feature/relay/relay_metrics.c
@@ -32,8 +32,10 @@
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/node_st.h"
#include "feature/nodelist/routerstatus_st.h"
+#include "feature/nodelist/torcert.h"
#include "feature/relay/relay_metrics.h"
#include "feature/relay/router.h"
+#include "feature/relay/routerkeys.h"
#include "feature/stats/rephist.h"
#include <event2/dns.h>
@@ -55,6 +57,7 @@ static void fill_streams_values(void);
static void fill_relay_flags(void);
static void fill_tcp_exhaustion_values(void);
static void fill_traffic_values(void);
+static void fill_signing_cert_expiry(void);
/** The base metrics that is a static array of metrics added to the metrics
* store.
@@ -174,6 +177,13 @@ static const relay_metrics_entry_t base_metrics[] =
.help = "Total number of circuits",
.fill_fn = fill_circuits_values,
},
+ {
+ .key = RELAY_METRICS_SIGNING_CERT_EXPIRY,
+ .type = METRICS_TYPE_GAUGE,
+ .name = METRICS_NAME(relay_signing_cert_expiry_timestamp),
+ .help = "Timestamp at which the current online keys will expire",
+ .fill_fn = fill_signing_cert_expiry,
+ },
};
static const size_t num_base_metrics = ARRAY_LENGTH(base_metrics);
@@ -991,6 +1001,25 @@ fill_oom_values(void)
metrics_store_entry_update(sentry, oom_stats_n_bytes_removed_hsdir);
}
+/** Fill function for the RELAY_METRICS_SIGNING_CERT_EXPIRY metrics. */
+static void
+fill_signing_cert_expiry(void)
+{
+ metrics_store_entry_t *sentry;
+ const tor_cert_t *signing_key;
+ const relay_metrics_entry_t *rentry =
+ &base_metrics[RELAY_METRICS_SIGNING_CERT_EXPIRY];
+
+ if (get_options()->OfflineMasterKey) {
+ signing_key = get_master_signing_key_cert();
+ if (signing_key) {
+ sentry = metrics_store_add(the_store, rentry->type, rentry->name,
+ rentry->help);
+ metrics_store_entry_update(sentry, signing_key->valid_until);
+ }
+ }
+}
+
/** Reset the global store and fill it with all the metrics from base_metrics
* and their associated values.
*
diff --git a/src/feature/relay/relay_metrics.h b/src/feature/relay/relay_metrics.h
index 1d2d649d8a..100815051b 100644
--- a/src/feature/relay/relay_metrics.h
+++ b/src/feature/relay/relay_metrics.h
@@ -47,6 +47,8 @@ typedef enum {
RELAY_METRICS_RELAY_FLAGS,
/** Numer of circuits. */
RELAY_METRICS_NUM_CIRCUITS,
+ /** Timestamp at which the current online keys will expire. */
+ RELAY_METRICS_SIGNING_CERT_EXPIRY
} relay_metrics_key_t;
/** The metadata of a relay metric. */