aboutsummaryrefslogtreecommitdiff
path: root/src/core/mainloop
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-10-20 14:47:05 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-10-27 10:43:42 -0400
commit2fe0322fe4550e59cb8757fbff6984286bf8e121 (patch)
treeaba4c9b3857465aa1a6d5adb52513a567ffe6d5a /src/core/mainloop
parent695957511b95d5b6cbe4a13d30b591aed572c9e5 (diff)
downloadtor-2fe0322fe4550e59cb8757fbff6984286bf8e121.tar.gz
tor-2fe0322fe4550e59cb8757fbff6984286bf8e121.zip
hs: Collect service traffic metrics
Related to #40063 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core/mainloop')
-rw-r--r--src/core/mainloop/connection.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index ebf15fcc9e..3d551c4ba8 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -99,6 +99,7 @@
#include "feature/hibernate/hibernate.h"
#include "feature/hs/hs_common.h"
#include "feature/hs/hs_ident.h"
+#include "feature/hs/hs_metrics.h"
#include "feature/metrics/metrics.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h"
@@ -4149,6 +4150,14 @@ connection_buf_read_from_socket(connection_t *conn, ssize_t *max_to_read,
/* change *max_to_read */
*max_to_read = at_most - n_read;
+ /* Onion service application connection. Note read bytes for metrics. */
+ if (CONN_IS_EDGE(conn) && TO_EDGE_CONN(conn)->hs_ident) {
+ edge_connection_t *edge_conn = TO_EDGE_CONN(conn);
+ hs_metrics_app_read_bytes(&edge_conn->hs_ident->identity_pk,
+ edge_conn->hs_ident->orig_virtual_port,
+ n_read);
+ }
+
/* Update edge_conn->n_read */
if (conn->type == CONN_TYPE_AP) {
edge_connection_t *edge_conn = TO_EDGE_CONN(conn);