aboutsummaryrefslogtreecommitdiff
path: root/src/feature/stats/rephist.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-10-12 09:25:01 -0400
committerDavid Goulet <dgoulet@torproject.org>2022-10-12 09:25:19 -0400
commitc8d8fa0d3639058544ffe153c1b83e0ed80bf43a (patch)
tree9d119551a7f30a0f315ac669b34b4d9f1e392978 /src/feature/stats/rephist.c
parentd543db5ac00548496b0d4e65052fb68958100cbf (diff)
downloadtor-c8d8fa0d3639058544ffe153c1b83e0ed80bf43a.tar.gz
tor-c8d8fa0d3639058544ffe153c1b83e0ed80bf43a.zip
relay: Add number of rejected connections to MetricsPort
Related to #40194 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/stats/rephist.c')
-rw-r--r--src/feature/stats/rephist.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c
index b272f27909..f12b1e8a70 100644
--- a/src/feature/stats/rephist.c
+++ b/src/feature/stats/rephist.c
@@ -1651,6 +1651,8 @@ rep_hist_note_exit_stream_opened(uint16_t port)
static uint64_t conn_num_created[2][CONN_TYPE_MAX_];
/** Number of connections opened per direction per type. */
static uint64_t conn_num_opened[2][CONN_TYPE_MAX_];
+/** Number of connections rejected per type. Always inbound. */
+static uint64_t conn_num_rejected[CONN_TYPE_MAX_];
/** Note that a connection has opened of the given type. */
void
@@ -1677,6 +1679,15 @@ rep_hist_note_conn_closed(bool from_listener, unsigned int type)
}
}
+/** Note that a connection has rejected of the given type. */
+void
+rep_hist_note_conn_rejected(unsigned int type)
+{
+ tor_assert(type <= CONN_TYPE_MAX_);
+
+ conn_num_rejected[type]++;
+}
+
/** Return number of created connections of the given type. */
uint64_t
rep_hist_get_conn_created(bool from_listener, unsigned int type)
@@ -1695,6 +1706,14 @@ rep_hist_get_conn_opened(bool from_listener, unsigned int type)
return conn_num_opened[dir][type];
}
+/** Return number of opened connections of the given type. */
+uint64_t
+rep_hist_get_conn_rejected(unsigned int type)
+{
+ tor_assert(type <= CONN_TYPE_MAX_);
+ return conn_num_rejected[type];
+}
+
/*** cell statistics ***/
/** Start of the current buffer stats interval or 0 if we're not