Loading changes/ticket29113 0 → 100644 +3 −0 Original line number Diff line number Diff line o Minor features (heartbeat): - Include the total number of inbound and outbound IPv4 and IPv6 connections in the heartbeat message . Closes ticket 29113. src/core/mainloop/connection.c +6 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ #include "core/or/policies.h" #include "core/or/reasons.h" #include "core/or/relay.h" #include "core/or/status.h" #include "core/or/crypt_path.h" #include "core/proto/proto_haproxy.h" #include "core/proto/proto_http.h" Loading Loading @@ -2042,6 +2043,9 @@ connection_handle_listener_read(connection_t *conn, int new_type) connection_mark_for_close(newconn); return 0; } note_connection(true /* inbound */, conn->socket_family); return 0; } Loading Loading @@ -2213,6 +2217,8 @@ connection_connect_sockaddr,(connection_t *conn, } } note_connection(false /* outbound */, conn->socket_family); /* it succeeded. we're connected. */ log_fn(inprogress ? LOG_DEBUG : LOG_INFO, LD_NET, "Connection to socket %s (sock "TOR_SOCKET_T_FORMAT").", Loading src/core/or/status.c +40 −1 Original line number Diff line number Diff line Loading @@ -113,6 +113,41 @@ log_onion_service_stats(void) hs_stats_get_n_rendezvous_launches()); } /** * @name connection counts for heartbeat * * Tracks incoming and outgoing connections on IPv4/IPv6, for heartbeat * logs. **/ /**@{*/ static unsigned n_incoming_ipv4; static unsigned n_incoming_ipv6; static unsigned n_outgoing_ipv4; static unsigned n_outgoing_ipv6; /**@}*/ /** * Note that a connection has arrived or has been made, for use in the * heartbeat message. **/ void note_connection(bool inbound, int family) { if (family == AF_INET) { if (inbound) { ++n_incoming_ipv4; } else { ++n_outgoing_ipv4; } } else if (family == AF_INET6) { if (inbound) { ++n_incoming_ipv6; } else { ++n_outgoing_ipv6; } } } /** Log a "heartbeat" message describing Tor's status and history so that the * user can know that there is indeed a running Tor. Return 0 on success and * -1 on failure. */ Loading Loading @@ -143,8 +178,12 @@ log_heartbeat(time_t now) bw_sent = bytes_to_usage(get_bytes_written()); log_fn(LOG_NOTICE, LD_HEARTBEAT, "Heartbeat: Tor's uptime is %s, with %d " "circuits open. I've sent %s and received %s.%s", "circuits open. I've sent %s and received %s. I've received %u " "connections on IPv4 and %u on IPv6. I've made %u connections " "with IPv4 and %u with IPv6.%s", uptime, count_circuits(), bw_sent, bw_rcvd, n_incoming_ipv4, n_incoming_ipv6, n_outgoing_ipv4, n_outgoing_ipv6, hibernating?" We are currently hibernating.":""); dirclient_dump_total_dls(); Loading src/core/or/status.h +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ #include "lib/testsupport/testsupport.h" void note_connection(bool inbound, int family); int log_heartbeat(time_t now); #ifdef STATUS_PRIVATE Loading src/test/test_status.c +65 −276 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
changes/ticket29113 0 → 100644 +3 −0 Original line number Diff line number Diff line o Minor features (heartbeat): - Include the total number of inbound and outbound IPv4 and IPv6 connections in the heartbeat message . Closes ticket 29113.
src/core/mainloop/connection.c +6 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ #include "core/or/policies.h" #include "core/or/reasons.h" #include "core/or/relay.h" #include "core/or/status.h" #include "core/or/crypt_path.h" #include "core/proto/proto_haproxy.h" #include "core/proto/proto_http.h" Loading Loading @@ -2042,6 +2043,9 @@ connection_handle_listener_read(connection_t *conn, int new_type) connection_mark_for_close(newconn); return 0; } note_connection(true /* inbound */, conn->socket_family); return 0; } Loading Loading @@ -2213,6 +2217,8 @@ connection_connect_sockaddr,(connection_t *conn, } } note_connection(false /* outbound */, conn->socket_family); /* it succeeded. we're connected. */ log_fn(inprogress ? LOG_DEBUG : LOG_INFO, LD_NET, "Connection to socket %s (sock "TOR_SOCKET_T_FORMAT").", Loading
src/core/or/status.c +40 −1 Original line number Diff line number Diff line Loading @@ -113,6 +113,41 @@ log_onion_service_stats(void) hs_stats_get_n_rendezvous_launches()); } /** * @name connection counts for heartbeat * * Tracks incoming and outgoing connections on IPv4/IPv6, for heartbeat * logs. **/ /**@{*/ static unsigned n_incoming_ipv4; static unsigned n_incoming_ipv6; static unsigned n_outgoing_ipv4; static unsigned n_outgoing_ipv6; /**@}*/ /** * Note that a connection has arrived or has been made, for use in the * heartbeat message. **/ void note_connection(bool inbound, int family) { if (family == AF_INET) { if (inbound) { ++n_incoming_ipv4; } else { ++n_outgoing_ipv4; } } else if (family == AF_INET6) { if (inbound) { ++n_incoming_ipv6; } else { ++n_outgoing_ipv6; } } } /** Log a "heartbeat" message describing Tor's status and history so that the * user can know that there is indeed a running Tor. Return 0 on success and * -1 on failure. */ Loading Loading @@ -143,8 +178,12 @@ log_heartbeat(time_t now) bw_sent = bytes_to_usage(get_bytes_written()); log_fn(LOG_NOTICE, LD_HEARTBEAT, "Heartbeat: Tor's uptime is %s, with %d " "circuits open. I've sent %s and received %s.%s", "circuits open. I've sent %s and received %s. I've received %u " "connections on IPv4 and %u on IPv6. I've made %u connections " "with IPv4 and %u with IPv6.%s", uptime, count_circuits(), bw_sent, bw_rcvd, n_incoming_ipv4, n_incoming_ipv6, n_outgoing_ipv4, n_outgoing_ipv6, hibernating?" We are currently hibernating.":""); dirclient_dump_total_dls(); Loading
src/core/or/status.h +1 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ #include "lib/testsupport/testsupport.h" void note_connection(bool inbound, int family); int log_heartbeat(time_t now); #ifdef STATUS_PRIVATE Loading
src/test/test_status.c +65 −276 File changed.Preview size limit exceeded, changes collapsed. Show changes