diff options
author | Roger Dingledine <arma@torproject.org> | 2008-12-27 06:50:07 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2008-12-27 06:50:07 +0000 |
commit | 5519e633ec4c48c5e547554ff750db1aab835cc7 (patch) | |
tree | 90b8cd8079bf9c4d1f0c25bd5e3c1365b07ec2f0 /src/or/control.c | |
parent | 0c5e03fa21ecdc5f484b8cef18fcbb611349b47f (diff) | |
download | tor-5519e633ec4c48c5e547554ff750db1aab835cc7.tar.gz tor-5519e633ec4c48c5e547554ff750db1aab835cc7.zip |
New controller event "clients_seen" to report a geoip-based summary
of which countries we've seen clients from recently. Now controllers
like Vidalia can show bridge operators that they're actually making
a difference.
svn:r17796
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/or/control.c b/src/or/control.c index 3c6c4fdb0e..e4ce5f3895 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -44,7 +44,8 @@ const char control_c_id[] = #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 @@ -125,7 +126,7 @@ static void send_control_event(uint16_t event, event_format_t which, 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); @@ -596,7 +597,7 @@ send_control_event_string(uint16_t event, event_format_t which, * 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 @@ -638,7 +639,7 @@ send_control_event_impl(uint16_t event, event_format_t which, int extended, * 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); @@ -658,7 +659,7 @@ send_control_event(uint16_t event, event_format_t which, * 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); @@ -3299,10 +3300,10 @@ control_event_stream_bandwidth_used(void) 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; } @@ -3319,9 +3320,9 @@ control_event_bandwidth_used(uint32_t n_read, uint32_t n_written) { 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; @@ -3695,11 +3696,11 @@ control_event_guard(const char *nickname, const char *digest, 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; } @@ -3947,3 +3948,14 @@ control_event_bootstrap_problem(const char *warn, int reason) 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); +} + |