mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
hs: Collect service traffic metrics
Related to #40063 Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
#include "feature/nodelist/describe.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "core/or/scheduler.h"
|
||||
#include "feature/hs/hs_metrics.h"
|
||||
|
||||
#include "core/or/cell_st.h"
|
||||
#include "core/or/cell_queue_st.h"
|
||||
@@ -1689,6 +1690,13 @@ handle_relay_cell_command(cell_t *cell, circuit_t *circ,
|
||||
circuit_read_valid_data(TO_ORIGIN_CIRCUIT(circ), rh->length);
|
||||
}
|
||||
|
||||
/* For onion service connection, update the metrics. */
|
||||
if (conn->hs_ident) {
|
||||
hs_metrics_app_write_bytes(&conn->hs_ident->identity_pk,
|
||||
conn->hs_ident->orig_virtual_port,
|
||||
rh->length);
|
||||
}
|
||||
|
||||
stats_n_data_bytes_received += rh->length;
|
||||
connection_buf_add((char*)(cell->payload + RELAY_HEADER_SIZE),
|
||||
rh->length, TO_CONN(conn));
|
||||
|
||||
Reference in New Issue
Block a user