[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Make sure that router_get_by_* can always return "me"



Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv26348/src/or

Modified Files:
	routerlist.c 
Log Message:
Make sure that router_get_by_* can always return "me"

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.214
retrieving revision 1.215
diff -u -d -r1.214 -r1.215
--- routerlist.c	25 Feb 2005 20:46:13 -0000	1.214
+++ routerlist.c	27 Feb 2005 07:23:42 -0000	1.215
@@ -582,6 +582,9 @@
     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 @@
 
   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);