Commit bc24c3f4 authored by Nick Mathewson's avatar Nick Mathewson 🐘
Browse files

Allow multiple ORs with same nickname in routerlist


svn:r2187
parent 05e9a226
Loading
Loading
Loading
Loading
+6 −12
Changes for src/or/routerlist.c: 6 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -440,17 +440,19 @@ void router_mark_as_down(const char *digest) {
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);
        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;
@@ -472,14 +474,6 @@ int router_add_to_routerlist(routerinfo_t *router) {
        routerinfo_free(router);
        return -1;
      }
      } 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'",
               router->nickname);
        routerinfo_free(router);
        return -1;
      }
    }
  }
  /* We haven't seen a router with this name before.  Add it to the end of