[or-cvs] Allow multiple ORs with same nickname in routerlist

Nick Mathewson nickm at seul.org
Sat Aug 7 03:38:09 UTC 2004


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

Modified Files:
	routerlist.c 
Log Message:
Allow multiple ORs with same nickname in routerlist

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- routerlist.c	6 Aug 2004 22:47:41 -0000	1.115
+++ routerlist.c	7 Aug 2004 03:38:07 -0000	1.116
@@ -440,43 +440,37 @@
 int router_add_to_routerlist(routerinfo_t *router) {
   int i;
   routerinfo_t *r;
+  char id_digest[DIGEST_LEN];
+
+  crypto_pk_get_digest(router->identity_pkey, id_digest);
+
   /* If we have a router with this name, and the identity key is the same,
    * choose the newer one. If the identity key has changed, drop the router.
    */
   for (i = 0; i < smartlist_len(routerlist->routers); ++i) {
     r = smartlist_get(routerlist->routers, i);
-    /* XXXX008 should just compare digests instead. */
-    if (!strcasecmp(router->nickname, r->nickname)) {
-      if (!crypto_pk_cmp_keys(router->identity_pkey, r->identity_pkey)) {
-        if (router->published_on > r->published_on) {
-          log_fn(LOG_DEBUG, "Replacing entry for router '%s'",
-                 router->nickname);
-          /* Remember whether we trust this router as a dirserver. */
-          if (r->is_trusted_dir)
-            router->is_trusted_dir = 1;
-          /* If the address hasn't changed; no need to re-resolve. */
-          if (!strcasecmp(r->address, router->address))
-            router->addr = r->addr;
-          routerinfo_free(r);
-          smartlist_set(routerlist->routers, i, router);
-          return 0;
-        } else {
-          log_fn(LOG_DEBUG, "Skipping old entry for router '%s'",
-                 router->nickname);
-          /* If we now trust 'router', then we trust the one in the routerlist
-           * too. */
-          if (router->is_trusted_dir)
-            r->is_trusted_dir = 1;
-          /* Update the is_running status to whatever we were told. */
-          r->is_running = router->is_running;
-          routerinfo_free(router);
-          return -1;
-        }
+    if (!crypto_pk_cmp_keys(router->identity_pkey, r->identity_pkey)) {
+      if (router->published_on > r->published_on) {
+        log_fn(LOG_DEBUG, "Replacing entry for router '%s/%s' [%s]",
+               router->nickname, r->nickname, hex_str(id_digest,DIGEST_LEN));
+        /* Remember whether we trust this router as a dirserver. */
+        if (r->is_trusted_dir)
+          router->is_trusted_dir = 1;
+        /* If the address hasn't changed; no need to re-resolve. */
+        if (!strcasecmp(r->address, router->address))
+          router->addr = r->addr;
+        routerinfo_free(r);
+        smartlist_set(routerlist->routers, i, router);
+        return 0;
       } else {
-        /* XXXX008 It's okay to have two keys for a nickname as soon as
-         * all the 007 clients are dead. */
-        log_fn(LOG_WARN, "Identity key mismatch for router '%s'",
+        log_fn(LOG_DEBUG, "Skipping old entry for router '%s'",
                router->nickname);
+        /* If we now trust 'router', then we trust the one in the routerlist
+         * too. */
+        if (router->is_trusted_dir)
+          r->is_trusted_dir = 1;
+        /* Update the is_running status to whatever we were told. */
+        r->is_running = router->is_running;
         routerinfo_free(router);
         return -1;
       }



More information about the tor-commits mailing list