diff options
author | George Kadianakis <desnacked@riseup.net> | 2020-08-25 15:43:00 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2020-08-25 15:43:00 +0300 |
commit | cc4e42ee3257d5157172cedb73ed86ba88ca271d (patch) | |
tree | f2f0aadbe7493da5c717912cc5c0386c253d16a7 /src/core/or | |
parent | 6dc0b043199d28866cdb466e18caebbf0b051c04 (diff) | |
parent | 24c721de37d2e10f5c864c2e8001f1468a8a4506 (diff) | |
download | tor-cc4e42ee3257d5157172cedb73ed86ba88ca271d.tar.gz tor-cc4e42ee3257d5157172cedb73ed86ba88ca271d.zip |
Merge remote-tracking branch 'tor-gitlab/mr/115'
Diffstat (limited to 'src/core/or')
-rw-r--r-- | src/core/or/status.c | 41 | ||||
-rw-r--r-- | src/core/or/status.h | 1 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/core/or/status.c b/src/core/or/status.c index ed8448883c..00a88a3178 100644 --- a/src/core/or/status.c +++ b/src/core/or/status.c @@ -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. */ @@ -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(); diff --git a/src/core/or/status.h b/src/core/or/status.h index 639f8cdf51..271e0dbc9a 100644 --- a/src/core/or/status.h +++ b/src/core/or/status.h @@ -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 |