mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Check fingerprint list before generating running-routers lists; also add as-yet-uncalled function to update an OR connection nickname on the fly
svn:r2458
This commit is contained in:
parent
fe54bd00b9
commit
9c49947163
@ -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>.
|
||||
*
|
||||
|
@ -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 = '$';
|
||||
|
@ -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 *****************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user