diff options
-rw-r--r-- | src/or/connection_or.c | 31 | ||||
-rw-r--r-- | src/or/dirserv.c | 7 | ||||
-rw-r--r-- | src/or/or.h | 2 |
3 files changed, 37 insertions, 3 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index fea307a3c..acff78b18 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -146,6 +146,37 @@ connection_or_init_conn_from_address(connection_t *conn, conn->address = tor_strdup(inet_ntoa(in)); } +void +connection_or_update_nickname(connection_t *conn) +{ + routerinfo_t *r; + const char *n; + + tor_assert(conn->type == CONN_TYPE_OR); + n = dirserv_get_nickname_by_digest(conn->identity_digest); + if (n) { + if (!conn->nickname || strcmp(conn->nickname, n)) { + tor_free(conn->nickname); + conn->nickname = tor_strdup(n); + } + return; + } + r = router_get_by_digest(conn->identity_digest); + if (r && r->is_verified) { + if (!conn->nickname || strcmp(conn->nickname, r->nickname)) { + tor_free(conn->nickname); + conn->nickname = tor_strdup(r->nickname); + } + return; + } + if (conn->nickname[0] != '$') { + tor_free(conn->nickname); + conn->nickname = tor_malloc(HEX_DIGEST_LEN+1); + base16_encode(conn->nickname, HEX_DIGEST_LEN+1, + conn->identity_digest, DIGEST_LEN); + } +} + /** Launch a new OR connection to <b>addr</b>:<b>port</b> and expect to * handshake with an OR with identity digest <b>id_digest</b>. * diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 7b34d645a..5f0e1d084 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -474,12 +474,13 @@ list_running_servers(char **nicknames_out) get_connection_array(&connection_array, &n_conns); for (i = 0; i<n_conns; ++i) { - char *name; + char *name, *cp; conn = connection_array[i]; if (conn->type != CONN_TYPE_OR || !conn->nickname) continue; /* only list ORs. */ - if (router_nickname_is_approved(conn->nickname, conn->identity_digest)) { - name = tor_strdup(conn->nickname); + cp = dirserv_get_nickname_by_digest(conn->identity_digest); + if (cp) { + name = tor_strdup(cp); } else { name = tor_malloc(HEX_DIGEST_LEN+2); *name = '$'; diff --git a/src/or/or.h b/src/or/or.h index b8a72ae2b..a15ab6126 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1160,6 +1160,8 @@ int connection_tls_start_handshake(connection_t *conn, int receiving); int connection_tls_continue_handshake(connection_t *conn); void connection_or_write_cell_to_buf(const cell_t *cell, connection_t *conn); +void connection_or_update_nickname(connection_t *conn); + /********************************* cpuworker.c *****************************/ |