diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-10-03 18:59:52 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-10-03 18:59:52 +0000 |
commit | 1ae7282d9b0faed2b9ea18be31eada2ee6a154be (patch) | |
tree | 756d948f6435a13321f23cba66cf12101d21ec1c /src/or/control.c | |
parent | ca0ebd0ba8b194f9ca29098219350e5cdd0731e6 (diff) | |
download | tor-1ae7282d9b0faed2b9ea18be31eada2ee6a154be.tar.gz tor-1ae7282d9b0faed2b9ea18be31eada2ee6a154be.zip |
r8857@totoro: nickm | 2006-10-03 13:54:21 -0400
Implement ORCONN with verbose names.
svn:r8588
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/or/control.c b/src/or/control.c index 49417dcb13..9a914717ee 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2323,7 +2323,7 @@ handle_control_usefeature(control_connection_t *conn, SMARTLIST_FOREACH(args, const char *, arg, { if (!strcasecmp(arg, "VERBOSE_NAMES")) verbose_names = 1; - if (!strcasecmp(arg, "EXTENDED_EVENTS")) + else if (!strcasecmp(arg, "EXTENDED_EVENTS")) extended_events = 1; else { connection_printf_to_buf(conn, "552 Unrecognized feature \"%s\"\r\n", @@ -2882,11 +2882,6 @@ control_event_or_conn_status(or_connection_t *conn,or_conn_status_event_t tp) if (EVENT_IS_INTERESTING1(EVENT_OR_CONN_STATUS)) { const char *status; char name[128]; - if (conn->nickname) - strlcpy(name, conn->nickname, sizeof(name)); - else - tor_snprintf(name, sizeof(name), "%s:%d", - conn->_base.address, conn->_base.port); switch (tp) { case OR_CONN_EVENT_LAUNCHED: status = "LAUNCHED"; break; @@ -2898,9 +2893,32 @@ control_event_or_conn_status(or_connection_t *conn,or_conn_status_event_t tp) log_warn(LD_BUG, "Unrecognized status code %d", (int)tp); return 0; } - send_control1_event(EVENT_OR_CONN_STATUS, ALL_NAMES/*XXXX NM*/, - "650 ORCONN %s %s\r\n", - name, status); + if (EVENT_IS_INTERESTING1S(EVENT_OR_CONN_STATUS)) { + if (conn->nickname) + strlcpy(name, conn->nickname, sizeof(name)); + else + tor_snprintf(name, sizeof(name), "%s:%d", + conn->_base.address, conn->_base.port); + send_control1_event(EVENT_OR_CONN_STATUS, SHORT_NAMES, + "650 ORCONN %s %s\r\n", + name, status); + } + if (EVENT_IS_INTERESTING1L(EVENT_OR_CONN_STATUS)) { + routerinfo_t *ri = router_get_by_digest(conn->identity_digest); + if (ri) { + router_get_verbose_nickname(name, ri); + } else if (! tor_digest_is_zero(conn->identity_digest)) { + name[0] = '$'; + base16_encode(name+1, sizeof(name)-1, conn->identity_digest, + DIGEST_LEN); + } else { + tor_snprintf(name, sizeof(name), "%s:%d", + conn->_base.address, conn->_base.port); + } + send_control1_event(EVENT_OR_CONN_STATUS, LONG_NAMES, + "650 ORCONN %s %s\r\n", + name, status); + } } return 0; } |