0 /* default */, 0, 1);
}
+/* Log a heartbeat message with some statistics. */
+void
+dos_log_heartbeat(void)
+{
+ char *conn_msg = NULL;
+ char *cc_msg = NULL;
+ char *single_hop_client_msg = NULL;
+
+ if (!dos_is_enabled()) {
+ goto end;
+ }
+
+ if (dos_cc_enabled) {
+ tor_asprintf(&cc_msg,
+ " %" PRIu64 " circuits rejected,"
+ " %" PRIu32 " marked addresses.",
+ cc_num_rejected_cells, cc_num_marked_addrs);
+ }
+
+ if (dos_conn_enabled) {
+ tor_asprintf(&conn_msg,
+ " %" PRIu64 " connections closed.",
+ conn_num_addr_rejected);
+ }
+
+ if (dos_should_refuse_single_hop_client()) {
+ tor_asprintf(&single_hop_client_msg,
+ " %" PRIu64 " single hop clients refused.",
+ num_single_hop_client_refused);
+ }
+
+ log_notice(LD_HEARTBEAT,
+ "DoS mitigation since startup:%s%s%s",
+ (cc_msg != NULL) ? cc_msg : " [cc not enabled]",
+ (conn_msg != NULL) ? conn_msg : " [conn not enabled]",
+ (single_hop_client_msg != NULL) ? single_hop_client_msg : "");
+
+ tor_free(conn_msg);
+ tor_free(cc_msg);
+ tor_free(single_hop_client_msg);
+
+ end:
+ return;
+}
+
/* Called when a new client connection has been established on the given
* address. */
void
void dos_free_all(void);
void dos_consensus_has_changed(const networkstatus_t *ns);
int dos_enabled(void);
+void dos_log_heartbeat(void);
void dos_new_client_conn(or_connection_t *or_conn);
void dos_close_client_conn(const or_connection_t *or_conn);
#include "hibernate.h"
#include "rephist.h"
#include "statefile.h"
+#include "dos.h"
static void log_accounting(const time_t now, const or_options_t *options);
#include "geoip.h"
if (public_server_mode(options)) {
rep_hist_log_circuit_handshake_stats(now);
rep_hist_log_link_protocol_counts();
+ dos_log_heartbeat();
}
circuit_log_ancient_one_hop_circuits(1800);