{Controllers may want to warn the user if this event occurs; further
action is generally not possible.}
- COSENSUS_ARRIVED
-
+ CONSENSUS_ARRIVED
Tor has received and validated a new consensus networkstatus.
(This event can be delayed a little while after the consensus
is received, if Tor needs to fetch certificates.)
These events apply only to streams entering Tor (such as on a SOCKSPort,
TransPort, or so on). They are not generated for exiting streams.
+4.1.14. Per-country client stats
+
+ The syntax is:
+ "650" SP "CLIENTS_SEEN" SP TimeStarted SP CountrySummary CRLF
+
+ We just generated a new summary of which countries we've seen clients
+ from recently. The controller could display this for the user, e.g.
+ in their "relay" configuration window, to give them a sense that they
+ are actually being useful.
+
+ Currently only bridge relays will receive this event, but once we figure
+ out how to sufficiently aggregate and sanitize the client counts on
+ main relays, we might start sending these events in other cases too.
+
+ TimeStarted is a quoted string indicating when the reported summary
+ counts from (in GMT).
+
+ The CountrySummary keyword has as its argument a comma-separated
+ set of "countrycode=count" pairs. For example,
+ 650-CLIENTS_SEEN TimeStarted="Thu Dec 25 23:50:43 EST 2008"
+ 650 CountrySummary=us=16,de=8,uk=8
+
5. Implementation notes
5.1. Authentication
#define EVENT_STATUS_GENERAL 0x0012
#define EVENT_GUARD 0x0013
#define EVENT_STREAM_BANDWIDTH_USED 0x0014
-#define _EVENT_MAX 0x0014
+#define EVENT_CLIENTS_SEEN 0x0015
+#define _EVENT_MAX 0x0015
/* If _EVENT_MAX ever hits 0x0020, we need to make the mask wider. */
/** Bitfield: The bit 1<<e is set if <b>any</b> open control
const char *format, ...)
CHECK_PRINTF(3,4);
static void send_control_event_extended(uint16_t event, event_format_t which,
- const char *format, ...)
+ const char *format, ...)
CHECK_PRINTF(3,4);
static int handle_control_setconf(control_connection_t *conn, uint32_t len,
char *body);
* ending \\r\\n\\0). */
static void
send_control_event_impl(uint16_t event, event_format_t which, int extended,
- const char *format, va_list ap)
+ const char *format, va_list ap)
{
/* This is just a little longer than the longest allowed log message */
#define SEND_CONTROL1_EVENT_BUFFERSIZE 10064
* ending \\n\\r\\0. */
static void
send_control_event(uint16_t event, event_format_t which,
- const char *format, ...)
+ const char *format, ...)
{
va_list ap;
va_start(ap, format);
* ending \\n\\r\\0. */
static void
send_control_event_extended(uint16_t event, event_format_t which,
- const char *format, ...)
+ const char *format, ...)
{
va_list ap;
va_start(ap, format);
continue;
send_control_event(EVENT_STREAM_BANDWIDTH_USED, ALL_NAMES,
- "650 STREAM_BW "U64_FORMAT" %lu %lu\r\n",
- U64_PRINTF_ARG(edge_conn->_base.global_identifier),
- (unsigned long)edge_conn->n_read,
- (unsigned long)edge_conn->n_written);
+ "650 STREAM_BW "U64_FORMAT" %lu %lu\r\n",
+ U64_PRINTF_ARG(edge_conn->_base.global_identifier),
+ (unsigned long)edge_conn->n_read,
+ (unsigned long)edge_conn->n_written);
edge_conn->n_written = edge_conn->n_read = 0;
}
{
if (EVENT_IS_INTERESTING(EVENT_BANDWIDTH_USED)) {
send_control_event(EVENT_BANDWIDTH_USED, ALL_NAMES,
- "650 BW %lu %lu\r\n",
- (unsigned long)n_read,
- (unsigned long)n_written);
+ "650 BW %lu %lu\r\n",
+ (unsigned long)n_read,
+ (unsigned long)n_written);
}
return 0;
tor_snprintf(buf, sizeof(buf), "$%s~%s", hbuf, nickname);
}
send_control_event(EVENT_GUARD, LONG_NAMES,
- "650 GUARD ENTRY %s %s\r\n", buf, status);
+ "650 GUARD ENTRY %s %s\r\n", buf, status);
}
if (EVENT_IS_INTERESTING1S(EVENT_GUARD)) {
send_control_event(EVENT_GUARD, SHORT_NAMES,
- "650 GUARD ENTRY $%s %s\r\n", hbuf, status);
+ "650 GUARD ENTRY $%s %s\r\n", hbuf, status);
}
return 0;
}
control_event_client_status(LOG_WARN, "%s", buf);
}
+/** We just generated a new summary of which countries we've seen clients
+ * from recently. Send a copy to the controller in case it wants to
+ * display it for the user. */
+void
+control_event_clients_seen(const char *timestarted, const char *countries)
+{
+ send_control_event(EVENT_CLIENTS_SEEN, 0,
+ "650 CLIENTS_SEEN Timestarted=\"%s\" CountrySummary=%s\r\n",
+ timestarted, countries);
+}
+