mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Remove router_get_by_{nickname,hexdigest} entirely
This commit is contained in:
+11
-5
@@ -1639,10 +1639,13 @@ getinfo_helper_dir(control_connection_t *control_conn,
|
||||
const char *question, char **answer,
|
||||
const char **errmsg)
|
||||
{
|
||||
const routerinfo_t *ri;
|
||||
const node_t *node;
|
||||
const routerinfo_t *ri = NULL;
|
||||
(void) control_conn;
|
||||
if (!strcmpstart(question, "desc/id/")) {
|
||||
ri = router_get_by_hexdigest(question+strlen("desc/id/"));
|
||||
node = node_get_by_hex_id(question+strlen("desc/id/"));
|
||||
if (node)
|
||||
ri = node->ri;
|
||||
if (ri) {
|
||||
const char *body = signed_descriptor_get_body(&ri->cache_info);
|
||||
if (body)
|
||||
@@ -1651,7 +1654,9 @@ getinfo_helper_dir(control_connection_t *control_conn,
|
||||
} else if (!strcmpstart(question, "desc/name/")) {
|
||||
/* XXX023 Setting 'warn_if_unnamed' here is a bit silly -- the
|
||||
* warning goes to the user, not to the controller. */
|
||||
ri = router_get_by_nickname(question+strlen("desc/name/"),1);
|
||||
node = node_get_by_nickname(question+strlen("desc/name/"), 1);
|
||||
if (node)
|
||||
ri = node->ri;
|
||||
if (ri) {
|
||||
const char *body = signed_descriptor_get_body(&ri->cache_info);
|
||||
if (body)
|
||||
@@ -1713,8 +1718,9 @@ getinfo_helper_dir(control_connection_t *control_conn,
|
||||
*answer = tor_strndup(md->body, md->bodylen);
|
||||
}
|
||||
} else if (!strcmpstart(question, "desc-annotations/id/")) {
|
||||
ri = router_get_by_hexdigest(question+
|
||||
strlen("desc-annotations/id/"));
|
||||
node = node_get_by_hex_id(question+strlen("desc-annotations/id/"));
|
||||
if (node)
|
||||
ri = node->ri;
|
||||
if (ri) {
|
||||
const char *annotations =
|
||||
signed_descriptor_get_annotations(&ri->cache_info);
|
||||
|
||||
@@ -2175,20 +2175,6 @@ router_nickname_matches(const routerinfo_t *router, const char *nickname)
|
||||
return router_hex_digest_matches(router, nickname);
|
||||
}
|
||||
|
||||
/** Return the router in our routerlist whose (case-insensitive)
|
||||
* nickname or (case-sensitive) hexadecimal key digest is
|
||||
* <b>nickname</b>. Return NULL if no such router is known.
|
||||
*/
|
||||
const routerinfo_t *
|
||||
router_get_by_nickname(const char *nickname, int warn_if_unnamed)
|
||||
{
|
||||
const node_t *node = node_get_by_nickname(nickname, warn_if_unnamed);
|
||||
if (node)
|
||||
return node->ri;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return true iff <b>digest</b> is the digest of the identity key of a
|
||||
* trusted directory matching at least one bit of <b>type</b>. If <b>type</b>
|
||||
* is zero, any authority is okay. */
|
||||
@@ -2235,18 +2221,6 @@ hexdigest_to_digest(const char *hexdigest, char *digest)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Return the router in our routerlist whose hexadecimal key digest
|
||||
* is <b>hexdigest</b>. Return NULL if no such router is known. */
|
||||
const routerinfo_t *
|
||||
router_get_by_hexdigest(const char *hexdigest)
|
||||
{
|
||||
if (is_legal_nickname(hexdigest))
|
||||
return NULL;
|
||||
|
||||
/* It's not a legal nickname, so it must be a hexdigest or nothing. */
|
||||
return router_get_by_nickname(hexdigest, 1);
|
||||
}
|
||||
|
||||
/** As router_get_by_id_digest,but return a pointer that you're allowed to
|
||||
* modify */
|
||||
routerinfo_t *
|
||||
|
||||
@@ -49,8 +49,6 @@ const node_t *router_choose_random_node(smartlist_t *excludedsmartlist,
|
||||
struct routerset_t *excludedset,
|
||||
router_crn_flags_t flags);
|
||||
|
||||
const routerinfo_t *router_get_by_nickname(const char *nickname,
|
||||
int warn_if_unnamed);
|
||||
int router_is_named(const routerinfo_t *router);
|
||||
int router_digest_is_trusted_dir_type(const char *digest,
|
||||
dirinfo_type_t type);
|
||||
@@ -59,7 +57,6 @@ int router_digest_is_trusted_dir_type(const char *digest,
|
||||
|
||||
int router_addr_is_trusted_dir(uint32_t addr);
|
||||
int hexdigest_to_digest(const char *hexdigest, char *digest);
|
||||
const routerinfo_t *router_get_by_hexdigest(const char *hexdigest);
|
||||
const routerinfo_t *router_get_by_id_digest(const char *digest);
|
||||
routerinfo_t *router_get_mutable_by_digest(const char *digest);
|
||||
signed_descriptor_t *router_get_by_descriptor_digest(const char *digest);
|
||||
|
||||
Reference in New Issue
Block a user