mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +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,15 +289,10 @@ circuit_list_path_impl(origin_circuit_t *circ, int verbose, int verbose_names)
|
|||||||
base16_encode(elt+1, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
|
base16_encode(elt+1, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
|
||||||
}
|
}
|
||||||
} else { /* ! verbose_names */
|
} 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 = tor_malloc(HEX_DIGEST_LEN+2);
|
||||||
elt[0] = '$';
|
elt[0] = '$';
|
||||||
base16_encode(elt+1, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
|
base16_encode(elt+1, HEX_DIGEST_LEN+1, id, DIGEST_LEN);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tor_assert(elt);
|
tor_assert(elt);
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
tor_assert(hop->state <= 2);
|
tor_assert(hop->state <= 2);
|
||||||
|
@ -774,17 +774,10 @@ node_get_by_hex_id(const char *hex_id)
|
|||||||
const node_t *node = node_get_by_id(digest_buf);
|
const node_t *node = node_get_by_id(digest_buf);
|
||||||
if (!node)
|
if (!node)
|
||||||
return NULL;
|
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 == '=') {
|
if (nn_char == '=') {
|
||||||
const char *named_id =
|
/* "=" indicates a Named relay, but there aren't any of those now. */
|
||||||
networkstatus_get_router_digest_by_nickname(nn_buf);
|
|
||||||
if (!named_id || tor_memneq(named_id, digest_buf, DIGEST_LEN))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1017,21 +1010,6 @@ node_get_nickname(const node_t *node)
|
|||||||
return NULL;
|
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
|
/** Return true iff <b>node</b> appears to be a directory authority or
|
||||||
* directory cache */
|
* directory cache */
|
||||||
int
|
int
|
||||||
@ -1079,13 +1057,12 @@ node_get_verbose_nickname(const node_t *node,
|
|||||||
char *verbose_name_out)
|
char *verbose_name_out)
|
||||||
{
|
{
|
||||||
const char *nickname = node_get_nickname(node);
|
const char *nickname = node_get_nickname(node);
|
||||||
int is_named = node_is_named(node);
|
|
||||||
verbose_name_out[0] = '$';
|
verbose_name_out[0] = '$';
|
||||||
base16_encode(verbose_name_out+1, HEX_DIGEST_LEN+1, node->identity,
|
base16_encode(verbose_name_out+1, HEX_DIGEST_LEN+1, node->identity,
|
||||||
DIGEST_LEN);
|
DIGEST_LEN);
|
||||||
if (!nickname)
|
if (!nickname)
|
||||||
return;
|
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);
|
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 1;
|
||||||
return hex_digest_nickname_matches(nickname,
|
return hex_digest_nickname_matches(nickname,
|
||||||
node->identity,
|
node->identity,
|
||||||
n,
|
n);
|
||||||
node_is_named(node));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return true iff <b>node</b> is named by some nickname in <b>lst</b>. */
|
/** 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);
|
char *verbose_name_out);
|
||||||
void node_get_verbose_nickname_by_id(const char *id_digest,
|
void node_get_verbose_nickname_by_id(const char *id_digest,
|
||||||
char *verbose_name_out);
|
char *verbose_name_out);
|
||||||
int node_is_named(const node_t *node);
|
|
||||||
int node_is_dir(const node_t *node);
|
int node_is_dir(const node_t *node);
|
||||||
int node_has_descriptor(const node_t *node);
|
int node_has_descriptor(const node_t *node);
|
||||||
int node_get_purpose(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. */
|
* <b>hexdigest</b> is malformed, or it doesn't match. */
|
||||||
int
|
int
|
||||||
hex_digest_nickname_matches(const char *hexdigest, const char *identity_digest,
|
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 digest[DIGEST_LEN];
|
||||||
char nn_char='\0';
|
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)
|
if (hex_digest_nickname_decode(hexdigest, digest, &nn_char, nn_buf) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (nn_char == '=' || nn_char == '~') {
|
if (nn_char == '=') {
|
||||||
if (!nickname)
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nn_char == '~') {
|
||||||
|
if (!nickname) // XXX This seems wrong. -NM
|
||||||
return 0;
|
return 0;
|
||||||
if (strcasecmp(nn_buf, nickname))
|
if (strcasecmp(nn_buf, nickname))
|
||||||
return 0;
|
return 0;
|
||||||
if (nn_char == '=' && !is_named)
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tor_memeq(digest, identity_digest, DIGEST_LEN);
|
return tor_memeq(digest, identity_digest, DIGEST_LEN);
|
||||||
|
@ -228,7 +228,7 @@ int hex_digest_nickname_decode(const char *hexdigest,
|
|||||||
char *nickname_out);
|
char *nickname_out);
|
||||||
int hex_digest_nickname_matches(const char *hexdigest,
|
int hex_digest_nickname_matches(const char *hexdigest,
|
||||||
const char *identity_digest,
|
const char *identity_digest,
|
||||||
const char *nickname, int is_named);
|
const char *nickname);
|
||||||
|
|
||||||
#ifdef ROUTERLIST_PRIVATE
|
#ifdef ROUTERLIST_PRIVATE
|
||||||
STATIC int choose_array_element_by_weight(const uint64_t *entries,
|
STATIC int choose_array_element_by_weight(const uint64_t *entries,
|
||||||
|
Loading…
Reference in New Issue
Block a user