15 #define STATUS_PRIVATE
33 #include "core/or/dos.h"
40 static void log_accounting(
const time_t now,
const or_options_t *options);
54 long int days = secs / 86400;
55 int hours = (int)((secs - (days * 86400)) / 3600);
56 int minutes = (int)((secs - (days * 86400) - (hours * 3600)) / 60);
57 char *uptime_string = NULL;
61 tor_asprintf(&uptime_string,
"%d:%02d hours", hours, minutes);
65 days, hours, minutes);
69 days, hours, minutes);
81 char *bw_string = NULL;
83 if (bytes < (1<<20)) {
85 }
else if (bytes < (1<<30)) {
86 double bw = ((double)bytes);
89 double bw = ((double)bytes);
103 if (num_services == 0) {
108 "Heartbeat: Our onion service%s received %u v3 INTRODUCE2 cells "
109 "and attempted to launch %d rendezvous circuits.",
110 num_services == 1 ?
"" :
"s",
122 static unsigned n_incoming_ipv4;
123 static unsigned n_incoming_ipv6;
124 static unsigned n_outgoing_ipv4;
125 static unsigned n_outgoing_ipv6;
135 if (family == AF_INET) {
141 }
else if (family == AF_INET6) {
156 char *bw_sent = NULL;
157 char *bw_rcvd = NULL;
172 "in the cached consensus.");
180 "circuits open. I've sent %s and received %s. I've received %u "
181 "connections on IPv4 and %u on IPv6. I've made %u connections "
182 "with IPv4 and %u with IPv6.%s",
184 n_incoming_ipv4, n_incoming_ipv6,
185 n_outgoing_ipv4, n_outgoing_ipv6,
186 hibernating?
" We are currently hibernating.":
"");
191 log_accounting(now, options);
194 double fullness_pct = 100;
200 const double overhead_pct = ( r - 1.0 ) * 100.0;
202 #define FULLNESS_PCT_THRESHOLD 80
203 #define TLS_OVERHEAD_THRESHOLD 15
205 const int severity = (fullness_pct < FULLNESS_PCT_THRESHOLD ||
206 overhead_pct > TLS_OVERHEAD_THRESHOLD)
210 "Average packaged cell fullness: %2.3f%%. "
211 "TLS write overhead: %.f%%", fullness_pct, overhead_pct);
235 "%"PRIu64
" successful returns, "
236 "%"PRIu64
" erroneous returns, and "
237 "%"PRIu64
" idle returns.",
238 (main_loop_success_count),
239 (main_loop_error_count),
240 (main_loop_idle_count));
254 log_accounting(
const time_t now,
const or_options_t *options)
257 char *acc_rcvd =
bytes_to_usage(state->AccountingBytesReadInInterval);
258 char *acc_sent =
bytes_to_usage(state->AccountingBytesWrittenInInterval);
263 char end_buf[ISO_TIME_LEN + 1];
264 char *remaining = NULL;
269 const char *acc_rule;
270 switch (options->AccountingRule) {
271 case ACCT_MAX: acc_rule =
"max";
273 case ACCT_SUM: acc_rule =
"sum";
275 case ACCT_OUT: acc_rule =
"out";
277 case ACCT_IN: acc_rule =
"in";
279 default: acc_rule =
"max";
283 log_notice(
LD_HEARTBEAT,
"Heartbeat: Accounting enabled. "
284 "Sent: %s, Received: %s, Used: %s / %s, Rule: %s. The "
285 "current accounting interval ends on %s, in %s.",
286 acc_sent, acc_rcvd, acc_used, acc_max, acc_rule, end_buf, remaining);
smartlist_t * circuit_get_global_list(void)
Header file for circuitlist.c.
void circuit_log_ancient_one_hop_circuits(int age)
Header file for circuituse.c.
const or_options_t * get_options(void)
Header file for config.c.
void dirclient_dump_total_dls(void)
Header file for dirclient.c.
Header file for geoip_stats.c.
char * format_client_stats_heartbeat(time_t now)
time_t accounting_get_end_time(void)
int accounting_is_enabled(const or_options_t *options)
int we_are_hibernating(void)
uint64_t get_accounting_bytes(void)
Header file for hibernate.c.
unsigned int hs_service_get_num_services(void)
Header file containing service data for the HS subsystem.
uint32_t hs_stats_get_n_introduce2_v3_cells(void)
uint32_t hs_stats_get_n_rendezvous_launches(void)
Header file for hs_stats.c.
#define log_fn(severity, domain, args,...)
uint64_t get_bytes_read(void)
uint64_t get_main_loop_error_count(void)
uint64_t get_main_loop_idle_count(void)
uint64_t get_main_loop_success_count(void)
uint64_t get_bytes_written(void)
Header file for mainloop.c.
const node_t * node_get_by_id(const char *identity_digest)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
#define RELAY_PAYLOAD_SIZE
The or_state_t structure, which represents Tor's state file.
int tor_asprintf(char **strp, const char *fmt,...)
uint64_t stats_n_data_cells_packaged
uint64_t stats_n_data_bytes_packaged
void rep_hist_log_link_protocol_counts(void)
void rep_hist_log_circuit_handshake_stats(time_t now)
Header file for rephist.c.
const routerinfo_t * router_get_my_routerinfo(void)
Header file for router.c.
Router descriptor structure.
int public_server_mode(const or_options_t *options)
int server_mode(const or_options_t *options)
Header file for routermode.c.
or_state_t * get_or_state(void)
STATIC char * bytes_to_usage(uint64_t bytes)
STATIC int count_circuits(void)
static void log_onion_service_stats(void)
STATIC char * secs_to_uptime(long secs)
int log_heartbeat(time_t now)
void note_connection(bool inbound, int family)
char identity_digest[DIGEST_LEN]
void format_local_iso_time(char *buf, time_t t)
double tls_get_write_overhead_ratio(void)