mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 13:43:47 +01:00
Remove some support for nickname-based hexdigests
We once used $X=N to mean "A relay with RSA ID digest X with the Named flag and the nickname N." But authorities no longer assign the Named flag.
This commit is contained in:
parent
40887b4d2e
commit
d7a3e336ee
@ -289,14 +289,9 @@ circuit_list_path_impl(origin_circuit_t *circ, int verbose, int verbose_names)
|
||||
base16_encode(elt+1, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
|
||||
}
|
||||
} else { /* ! verbose_names */
|
||||
node = node_get_by_id(id);
|
||||
if (node && node_is_named(node)) {
|
||||
elt = tor_strdup(node_get_nickname(node));
|
||||
} else {
|
||||
elt = tor_malloc(HEX_DIGEST_LEN+2);
|
||||
elt[0] = '$';
|
||||
base16_encode(elt+1, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
|
||||
}
|
||||
elt = tor_malloc(HEX_DIGEST_LEN+2);
|
||||
elt[0] = '$';
|
||||
base16_encode(elt+1, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
|
||||
}
|
||||
tor_assert(elt);
|
||||
if (verbose) {
|
||||
|
@ -774,16 +774,9 @@ node_get_by_hex_id(const char *hex_id)
|
||||
const node_t *node = node_get_by_id(digest_buf);
|
||||
if (!node)
|
||||
return NULL;
|
||||
if (nn_char) {
|
||||
const char *real_name = node_get_nickname(node);
|
||||
if (!real_name || strcasecmp(real_name, nn_buf))
|
||||
return NULL;
|
||||
if (nn_char == '=') {
|
||||
const char *named_id =
|
||||
networkstatus_get_router_digest_by_nickname(nn_buf);
|
||||
if (!named_id || tor_memneq(named_id, digest_buf, DIGEST_LEN))
|
||||
return NULL;
|
||||
}
|
||||
if (nn_char == '=') {
|
||||
/* "=" indicates a Named relay, but there aren't any of those now. */
|
||||
return NULL;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@ -1017,21 +1010,6 @@ node_get_nickname(const node_t *node)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return true iff the nickname of <b>node</b> is canonical, based on the
|
||||
* latest consensus. */
|
||||
int
|
||||
node_is_named(const node_t *node)
|
||||
{
|
||||
const char *named_id;
|
||||
const char *nickname = node_get_nickname(node);
|
||||
if (!nickname)
|
||||
return 0;
|
||||
named_id = networkstatus_get_router_digest_by_nickname(nickname);
|
||||
if (!named_id)
|
||||
return 0;
|
||||
return tor_memeq(named_id, node->identity, DIGEST_LEN);
|
||||
}
|
||||
|
||||
/** Return true iff <b>node</b> appears to be a directory authority or
|
||||
* directory cache */
|
||||
int
|
||||
@ -1079,13 +1057,12 @@ node_get_verbose_nickname(const node_t *node,
|
||||
char *verbose_name_out)
|
||||
{
|
||||
const char *nickname = node_get_nickname(node);
|
||||
int is_named = node_is_named(node);
|
||||
verbose_name_out[0] = '$';
|
||||
base16_encode(verbose_name_out+1, HEX_DIGEST_LEN+1, node->identity,
|
||||
DIGEST_LEN);
|
||||
if (!nickname)
|
||||
return;
|
||||
verbose_name_out[1+HEX_DIGEST_LEN] = is_named ? '=' : '~';
|
||||
verbose_name_out[1+HEX_DIGEST_LEN] = '~';
|
||||
strlcpy(verbose_name_out+1+HEX_DIGEST_LEN+1, nickname, MAX_NICKNAME_LEN+1);
|
||||
}
|
||||
|
||||
@ -1640,8 +1617,7 @@ node_nickname_matches(const node_t *node, const char *nickname)
|
||||
return 1;
|
||||
return hex_digest_nickname_matches(nickname,
|
||||
node->identity,
|
||||
n,
|
||||
node_is_named(node));
|
||||
n);
|
||||
}
|
||||
|
||||
/** Return true iff <b>node</b> is named by some nickname in <b>lst</b>. */
|
||||
|
@ -40,7 +40,6 @@ void node_get_verbose_nickname(const node_t *node,
|
||||
char *verbose_name_out);
|
||||
void node_get_verbose_nickname_by_id(const char *id_digest,
|
||||
char *verbose_name_out);
|
||||
int node_is_named(const node_t *node);
|
||||
int node_is_dir(const node_t *node);
|
||||
int node_has_descriptor(const node_t *node);
|
||||
int node_get_purpose(const node_t *node);
|
||||
|
@ -2926,7 +2926,7 @@ hex_digest_nickname_decode(const char *hexdigest,
|
||||
* <b>hexdigest</b> is malformed, or it doesn't match. */
|
||||
int
|
||||
hex_digest_nickname_matches(const char *hexdigest, const char *identity_digest,
|
||||
const char *nickname, int is_named)
|
||||
const char *nickname)
|
||||
{
|
||||
char digest[DIGEST_LEN];
|
||||
char nn_char='\0';
|
||||
@ -2935,13 +2935,15 @@ hex_digest_nickname_matches(const char *hexdigest, const char *identity_digest,
|
||||
if (hex_digest_nickname_decode(hexdigest, digest, &nn_char, nn_buf) == -1)
|
||||
return 0;
|
||||
|
||||
if (nn_char == '=' || nn_char == '~') {
|
||||
if (!nickname)
|
||||
if (nn_char == '=') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nn_char == '~') {
|
||||
if (!nickname) // XXX This seems wrong. -NM
|
||||
return 0;
|
||||
if (strcasecmp(nn_buf, nickname))
|
||||
return 0;
|
||||
if (nn_char == '=' && !is_named)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tor_memeq(digest, identity_digest, DIGEST_LEN);
|
||||
|
@ -228,7 +228,7 @@ int hex_digest_nickname_decode(const char *hexdigest,
|
||||
char *nickname_out);
|
||||
int hex_digest_nickname_matches(const char *hexdigest,
|
||||
const char *identity_digest,
|
||||
const char *nickname, int is_named);
|
||||
const char *nickname);
|
||||
|
||||
#ifdef ROUTERLIST_PRIVATE
|
||||
STATIC int choose_array_element_by_weight(const uint64_t *entries,
|
||||
|
Loading…
Reference in New Issue
Block a user