diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-12-15 22:40:20 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-12-15 22:40:20 +0000 |
commit | 31e09bb5242b24d50fcc306fc3b423e0468e1726 (patch) | |
tree | 9f93cc8f79ad0b66c4270a76eb283fdcf6e59137 /src/or/control.c | |
parent | 251f007b75aaef7755dd45069c54ee6786f3a013 (diff) | |
download | tor-31e09bb5242b24d50fcc306fc3b423e0468e1726.tar.gz tor-31e09bb5242b24d50fcc306fc3b423e0468e1726.zip |
r11614@Kushana: nickm | 2006-12-15 17:39:42 -0500
Implement SETEVENTS GUARD. Needs review and testing.
svn:r9137
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/or/control.c b/src/or/control.c index f5b0d5223f..90ab2ca0cc 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -86,7 +86,8 @@ const char control_c_id[] = #define EVENT_STATUS_CLIENT 0x0010 #define EVENT_STATUS_SERVER 0x0011 #define EVENT_STATUS_GENERAL 0x0012 -#define _EVENT_MAX 0x0012 +#define EVENT_GUARD 0x0013 +#define _EVENT_MAX 0x0013 /* If _EVENT_MAX ever hits 0x0020, we need to make the mask wider. */ /** Array mapping from message type codes to human-readable message @@ -1064,6 +1065,8 @@ handle_control_setevents(control_connection_t *conn, uint32_t len, event_code = EVENT_STATUS_CLIENT; else if (!strcasecmp(ev, "STATUS_SERVER")) event_code = EVENT_STATUS_SERVER; + else if (!strcasecmp(ev, "GUARD")) + event_code = EVENT_GUARD; else { connection_printf_to_buf(conn, "552 Unrecognized event \"%s\"\r\n", ev); @@ -3650,6 +3653,34 @@ control_event_server_status(int severity, const char *format, ...) return r; } +/** DOCDOC */ +int +control_event_guard(const char *nickname, const char *digest, + const char *status) +{ + char hbuf[HEX_DIGEST_LEN+1]; + base16_encode(hbuf, sizeof(hbuf), digest, DIGEST_LEN); + if (!EVENT_IS_INTERESTING1(EVENT_GUARD)) + return 0; + + if (EVENT_IS_INTERESTING1L(EVENT_GUARD)) { + char buf[MAX_VERBOSE_NICKNAME_LEN+1]; + routerinfo_t *ri = router_get_by_digest(digest); + if (ri) { + router_get_verbose_nickname(buf, ri); + } else { + tor_snprintf(buf, sizeof(buf), "$%s~%s", hbuf, nickname); + } + send_control1_event(EVENT_GUARD, LONG_NAMES, + "650 GUARD ENTRY %s %s\r\n", buf, status); + } + if (EVENT_IS_INTERESTING1S(EVENT_GUARD)) { + send_control1_event(EVENT_GUARD, SHORT_NAMES, + "650 GUARD ENTRY $%s %s\r\n", hbuf, status); + } + return 0; +} + /** Choose a random authentication cookie and write it to disk. * Anybody who can read the cookie from disk will be considered * authorized to use the control connection. */ |