summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-02-27 07:23:42 +0000
committerNick Mathewson <nickm@torproject.org>2005-02-27 07:23:42 +0000
commit8efb2a957d8b7a59daae3927eed7d6bf0dde7ea2 (patch)
tree174dfaff04e7f9162a2f4b267db5e047f9a4b7f2
parent1630fa560fba4f505801a94b5b473e05caabe78b (diff)
downloadtor-8efb2a957d8b7a59daae3927eed7d6bf0dde7ea2.tar.gz
tor-8efb2a957d8b7a59daae3927eed7d6bf0dde7ea2.zip
Make sure that router_get_by_* can always return "me"
svn:r3702
-rw-r--r--doc/TODO4
-rw-r--r--src/or/routerlist.c7
2 files changed, 9 insertions, 2 deletions
diff --git a/doc/TODO b/doc/TODO
index 38fb32fda2..c426d58172 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -209,8 +209,8 @@ N - IPv6 support (For exit addresses)
extend-data cells can be extend requests.
- Code cleanup
- - fix router_get_by_* functions so they can get ourselves too,
- and audit everything to make sure rend and intro points are
+ o fix router_get_by_* functions so they can get ourselves too ...
+ - and audit everything to make sure rend and intro points are
just as likely to be us as not.
- tor should be able to have a pool of outgoing IP addresses
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index d3b9ebb295..360d46d865 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -582,6 +582,9 @@ routerinfo_t *router_get_by_nickname(const char *nickname)
return NULL;
if (nickname[0] == '$')
return router_get_by_hexdigest(nickname);
+ if (server_mode(get_options()) &&
+ !strcasecmp(nickname, get_options()->Nickname))
+ return router_get_my_routerinfo();
maybedigest = (strlen(nickname) == HEX_DIGEST_LEN) &&
(base16_decode(digest,DIGEST_LEN,nickname,HEX_DIGEST_LEN) == 0);
@@ -632,6 +635,10 @@ routerinfo_t *router_get_by_digest(const char *digest) {
tor_assert(digest);
if (!routerlist) return NULL;
+ if (server_mode(get_options()) &&
+ (router = router_get_my_routerinfo()) &&
+ !memcmp(digest, router->identity_digest, DIGEST_LEN))
+ return router;
for (i=0;i<smartlist_len(routerlist->routers);i++) {
router = smartlist_get(routerlist->routers, i);