From 80d3887360548b28fe2bd06501f0d51d0a1ba4f0 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 22 Aug 2017 19:04:31 -0400 Subject: Refactor node lookup APIs to take flags Right now there's a single warn_if_unnamed flag for router_get_consensus_status_by_nickname() and node_get_by_nickname(), that is nearly always 1. I've turned it into an 'unsigned' bitfield, and inverted its sense. I've added the flags argument to node_get_by_hex_id() too, though it does nothing there right now. I've removed the router_get_consensus_status_by_nickname() function, since it was only used in once place. This patch changes the warning behavior of GETINFO ns/name/, since all other name lookups from the controller currently warn. Later I'm going to add more flags, for ed25519 support. --- src/or/networkstatus.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/or/networkstatus.c') diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 69bff55cff..6263be36c3 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -794,21 +794,6 @@ router_get_consensus_status_by_id(const char *digest) return router_get_mutable_consensus_status_by_id(digest); } -/** Given a nickname (possibly verbose, possibly a hexadecimal digest), return - * the corresponding routerstatus_t, or NULL if none exists. Warn the - * user if warn_if_unnamed is set, and they have specified a router by - * nickname, but the Named flag isn't set for that router. */ -const routerstatus_t * -router_get_consensus_status_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->rs; - else - return NULL; -} - /** Return the identity digest that's mapped to officially by * nickname. */ const char * @@ -2555,7 +2540,8 @@ getinfo_helper_networkstatus(control_connection_t *conn, } status = router_get_consensus_status_by_id(d); } else if (!strcmpstart(question, "ns/name/")) { - status = router_get_consensus_status_by_nickname(question+8, 0); + const node_t *n = node_get_by_nickname(question+8, 0); + status = n ? n->rs : NULL; } else if (!strcmpstart(question, "ns/purpose/")) { *answer = networkstatus_getinfo_by_purpose(question+11, time(NULL)); return *answer ? 0 : -1; -- cgit v1.2.3-54-g00ecf