[tor-commits] [tor/master] Merge remote-tracking branch 'origin/maint-0.2.2'

nickm at torproject.org nickm at torproject.org
Mon May 30 19:41:02 UTC 2011


commit fa1d47293b62fd378a7e43cf3ce3e7bb3be884e3
Merge: 21de9d4 7f0fb8e
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon May 30 15:41:46 2011 -0400

    Merge remote-tracking branch 'origin/maint-0.2.2'
    
    The conflicts were mainly caused by the routerinfo->node transition.
    
    Conflicts:
    	src/or/circuitbuild.c
    	src/or/command.c
    	src/or/connection_edge.c
    	src/or/directory.c
    	src/or/dirserv.c
    	src/or/relay.c
    	src/or/rendservice.c
    	src/or/routerlist.c

 changes/bug3045              |    6 ++
 src/common/compat_libevent.h |    5 +-
 src/common/util.h            |    2 +-
 src/or/circuitbuild.c        |   44 ++++++-----
 src/or/circuitlist.c         |    6 +-
 src/or/circuituse.c          |    4 +-
 src/or/command.c             |    4 +-
 src/or/connection_edge.c     |    6 +-
 src/or/directory.c           |    7 +-
 src/or/dirserv.c             |   47 ++++++-----
 src/or/relay.c               |    5 +-
 src/or/rendclient.c          |   19 +++--
 src/or/rendservice.c         |   31 ++++---
 src/or/rephist.c             |    6 +-
 src/or/router.c              |  180 ++++++++++++++++++++++++++++++++++++++++++
 src/or/router.h              |   24 ++++++
 src/or/routerlist.c          |   38 +++++-----
 src/or/routerlist.h          |    1 +
 src/or/routerparse.c         |    5 +-
 19 files changed, 339 insertions(+), 101 deletions(-)

diff --cc src/common/compat_libevent.h
index 496544d,89b2563..8669fd4
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@@ -8,15 -8,10 +8,13 @@@
  
  struct event;
  struct event_base;
 +#ifdef USE_BUFFEREVENTS
 +struct bufferevent;
 +#endif
  
- 
  #ifdef HAVE_EVENT2_EVENT_H
  #include <event2/util.h>
- #else
- #ifndef EVUTIL_SOCKET_DEFINED
+ #elif !defined(EVUTIL_SOCKET_DEFINED)
  #define EVUTIL_SOCKET_DEFINED
  #define evutil_socket_t int
  #endif
diff --cc src/or/circuitbuild.c
index 34bb1fd,2f70b67..8140cc4
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@@ -2034,7 -2038,7 +2033,7 @@@ circuit_send_next_onion_skin(origin_cir
      circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
      log_info(LD_CIRC,"First hop: finished sending %s cell to '%s'",
               fast ? "CREATE_FAST" : "CREATE",
-              node ? node_get_nickname(node) : "<unnamed>");
 -             router ? router_describe(router) : "<unnamed>");
++             node ? node_describe(node) : "<unnamed>");
    } else {
      tor_assert(circ->cpath->state == CPATH_STATE_OPEN);
      tor_assert(circ->_base.state == CIRCUIT_STATE_BUILDING);
@@@ -2817,9 -2827,9 +2816,9 @@@ choose_good_exit_server_general(int nee
    }
  
    tor_free(n_supported);
 -  if (router) {
 -    log_info(LD_CIRC, "Chose exit server '%s'", router_describe(router));
 -    return router;
 +  if (node) {
-     log_info(LD_CIRC, "Chose exit server '%s'", node_get_nickname(node));
++    log_info(LD_CIRC, "Chose exit server '%s'", node_describe(node));
 +    return node;
    }
    if (options->ExitNodes) {
      log_warn(LD_CIRC,
@@@ -2964,13 -2975,14 +2963,14 @@@ onion_pick_cpath_exit(origin_circuit_t 
  
    if (exit) { /* the circuit-builder pre-requested one */
      warn_if_last_router_excluded(circ, exit);
-     log_info(LD_CIRC,"Using requested exit node '%s'", exit->nickname);
+     log_info(LD_CIRC,"Using requested exit node '%s'",
+              extend_info_describe(exit));
      exit = extend_info_dup(exit);
    } else { /* we have to decide one */
 -    routerinfo_t *router =
 -      choose_good_exit_server(circ->_base.purpose, rl, state->need_uptime,
 +    const node_t *node =
 +      choose_good_exit_server(circ->_base.purpose, state->need_uptime,
                                state->need_capacity, state->is_internal);
 -    if (!router) {
 +    if (!node) {
        log_warn(LD_CIRC,"failed to choose an exit server");
        return -1;
      }
@@@ -3622,10 -3612,10 +3627,10 @@@ add_an_entry_guard(const node_t *chosen
        return NULL;
    }
    entry = tor_malloc_zero(sizeof(entry_guard_t));
--  log_info(LD_CIRC, "Chose '%s' as new entry guard.",
-            node_get_nickname(node));
 -           router_describe(router));
 -  strlcpy(entry->nickname, router->nickname, sizeof(entry->nickname));
 -  memcpy(entry->identity, router->cache_info.identity_digest, DIGEST_LEN);
++  log_info(LD_CIRC, "Chose %s as new entry guard.",
++           node_describe(node));
 +  strlcpy(entry->nickname, node_get_nickname(node), sizeof(entry->nickname));
 +  memcpy(entry->identity, node->identity, DIGEST_LEN);
    /* Choose expiry time smudged over the past month. The goal here
     * is to a) spread out when Tor clients rotate their guards, so they
     * don't all select them on the same day, and b) avoid leaving a
@@@ -3812,9 -3802,10 +3817,10 @@@ entry_guards_compute_status(or_options_
      SMARTLIST_FOREACH_BEGIN(entry_guards, entry_guard_t *, entry) {
        const char *reason = digestmap_get(reasons, entry->identity);
        const char *live_msg = "";
 -      routerinfo_t *r = entry_is_live(entry, 0, 1, 0, &live_msg);
 +      const node_t *r = entry_is_live(entry, 0, 1, 0, &live_msg);
-       log_info(LD_CIRC, "Summary: Entry '%s' is %s, %s%s%s, and %s%s.",
+       log_info(LD_CIRC, "Summary: Entry %s [%s] is %s, %s%s%s, and %s%s.",
                 entry->nickname,
+                hex_str(entry->identity, DIGEST_LEN),
                 entry->unreachable_since ? "unreachable" : "reachable",
                 entry->bad_since ? "unusable" : "usable",
                 reason ? ", ": "",
diff --cc src/or/command.c
index 994bc86,12b4c30..d24373e
--- a/src/or/command.c
+++ b/src/or/command.c
@@@ -273,13 -272,10 +273,13 @@@ command_process_create_cell(cell_t *cel
             "Received CREATE cell (circID %d) for known circ. "
             "Dropping (age %d).",
             cell->circ_id, (int)(time(NULL) - conn->_base.timestamp_created));
 -    if (router)
 +    if (node) {
 +      char *p = esc_for_log(node_get_platform(node));
        log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
-              "Details: nickname \"%s\", platform %s.",
-              node_get_nickname(node), p);
+              "Details: router %s, platform %s.",
 -             router_describe(router), escaped(router->platform));
++             node_describe(node), p);
 +      tor_free(p);
 +    }
      return;
    }
  
diff --cc src/or/connection_edge.c
index ec3b417,78b1b92..273a962
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@@ -1830,7 -1830,8 +1830,7 @@@ connection_ap_handshake_rewrite_and_att
          if (r) {
            log_info(LD_APP,
                     "Redirecting address %s to exit at enclave router %s",
-                    safe_str_client(socks->address), node_get_nickname(r));
 -                   safe_str_client(socks->address),
 -                   router_describe(r));
++                   safe_str_client(socks->address), node_describe(r));
            /* use the hex digest, not nickname, in case there are two
               routers with this nickname */
            conn->chosen_exit_name =
diff --cc src/or/directory.c
index 810612c,52fec6b..e7a2a4b
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@@ -554,15 -522,15 +554,16 @@@ directory_initiate_command_routerstatus
    struct in_addr in;
    const char *address;
    tor_addr_t addr;
 -  router = router_get_by_digest(status->identity_digest);
 +  node = node_get_by_id(status->identity_digest);
  
 -  if (!router && anonymized_connection) {
 -    log_info(LD_DIR, "Not sending anonymized request to directory %s; we "
 +  if (!node && anonymized_connection) {
 +    log_info(LD_DIR, "Not sending anonymized request to directory '%s'; we "
-                      "don't have its router descriptor.", status->nickname);
+              "don't have its router descriptor.",
+              routerstatus_describe(status));
      return;
 -  } else if (router) {
 -    address = router->address;
 +  } else if (node) {
 +    node_get_address_string(node, address_buf, sizeof(address_buf));
 +    address = address_buf;
    } else {
      in.s_addr = htonl(status->addr);
      tor_inet_ntoa(&in, address_buf, sizeof(address_buf));
@@@ -571,11 -539,11 +572,11 @@@
    tor_addr_from_ipv4h(&addr, status->addr);
  
    if (options->ExcludeNodes && options->StrictNodes &&
 -      routerset_contains_routerstatus(options->ExcludeNodes, status)) {
 +      routerset_contains_routerstatus(options->ExcludeNodes, status, -1)) {
-     log_warn(LD_DIR, "Wanted to contact directory mirror '%s' for %s, but "
+     log_warn(LD_DIR, "Wanted to contact directory mirror %s for %s, but "
               "it's in our ExcludedNodes list and StrictNodes is set. "
               "Skipping. This choice might make your Tor not work.",
-              status->nickname,
+              routerstatus_describe(status),
               dir_conn_purpose_to_string(dir_purpose));
      return;
    }
diff --cc src/or/dirserv.c
index aa2e74b,e9355fe..c591d90
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@@ -823,60 -819,52 +827,62 @@@ dirserv_add_extrainfo(extrainfo_t *ei, 
  static void
  directory_remove_invalid(void)
  {
 -  int i;
    int changed = 0;
    routerlist_t *rl = router_get_routerlist();
 +  smartlist_t *nodes = smartlist_create();
 +  smartlist_add_all(nodes, nodelist_get_list());
  
 -  routerlist_assert_ok(rl);
 -
 -  for (i = 0; i < smartlist_len(rl->routers); ++i) {
 +  SMARTLIST_FOREACH_BEGIN(nodes, node_t *, node) {
      const char *msg;
 -    routerinfo_t *ent = smartlist_get(rl->routers, i);
 +    routerinfo_t *ent = node->ri;
+     char description[NODE_DESC_BUF_LEN];
 -    uint32_t r = dirserv_router_get_status(ent, &msg);
 +    uint32_t r;
 +    if (!ent)
 +      continue;
 +    r = dirserv_router_get_status(ent, &msg);
+     router_get_description(description, ent);
      if (r & FP_REJECT) {
-       log_info(LD_DIRSERV, "Router '%s' is now rejected: %s",
-                ent->nickname, msg?msg:"");
+       log_info(LD_DIRSERV, "Router %s is now rejected: %s",
+                description, msg?msg:"");
        routerlist_remove(rl, ent, 0, time(NULL));
        changed = 1;
        continue;
      }
 -    if (bool_neq((r & FP_NAMED), ent->is_named)) {
 +#if 0
 +    if (bool_neq((r & FP_NAMED), ent->auth_says_is_named)) {
        log_info(LD_DIRSERV,
-                "Router '%s' is now %snamed.", ent->nickname,
+                "Router %s is now %snamed.", description,
                 (r&FP_NAMED)?"":"un");
        ent->is_named = (r&FP_NAMED)?1:0;
        changed = 1;
      }
 -    if (bool_neq((r & FP_INVALID), !ent->is_valid)) {
 +    if (bool_neq((r & FP_UNNAMED), ent->auth_says_is_unnamed)) {
 +      log_info(LD_DIRSERV,
-                "Router '%s' is now %snamed. (FP_UNNAMED)", ent->nickname,
++               "Router '%s' is now %snamed. (FP_UNNAMED)", description,
 +               (r&FP_NAMED)?"":"un");
 +      ent->is_named = (r&FP_NUNAMED)?0:1;
 +      changed = 1;
 +    }
 +#endif
 +    if (bool_neq((r & FP_INVALID), !node->is_valid)) {
-       log_info(LD_DIRSERV, "Router '%s' is now %svalid.", ent->nickname,
+       log_info(LD_DIRSERV, "Router '%s' is now %svalid.", description,
                 (r&FP_INVALID) ? "in" : "");
 -      ent->is_valid = (r&FP_INVALID)?0:1;
 +      node->is_valid = (r&FP_INVALID)?0:1;
        changed = 1;
      }
 -    if (bool_neq((r & FP_BADDIR), ent->is_bad_directory)) {
 +    if (bool_neq((r & FP_BADDIR), node->is_bad_directory)) {
-       log_info(LD_DIRSERV, "Router '%s' is now a %s directory", ent->nickname,
+       log_info(LD_DIRSERV, "Router '%s' is now a %s directory", description,
                 (r & FP_BADDIR) ? "bad" : "good");
 -      ent->is_bad_directory = (r&FP_BADDIR) ? 1: 0;
 +      node->is_bad_directory = (r&FP_BADDIR) ? 1: 0;
        changed = 1;
      }
 -    if (bool_neq((r & FP_BADEXIT), ent->is_bad_exit)) {
 +    if (bool_neq((r & FP_BADEXIT), node->is_bad_exit)) {
-       log_info(LD_DIRSERV, "Router '%s' is now a %s exit", ent->nickname,
+       log_info(LD_DIRSERV, "Router '%s' is now a %s exit", description,
                 (r & FP_BADEXIT) ? "bad" : "good");
 -      ent->is_bad_exit = (r&FP_BADEXIT) ? 1: 0;
 +      node->is_bad_exit = (r&FP_BADEXIT) ? 1: 0;
        changed = 1;
      }
 -  }
 +  } SMARTLIST_FOREACH_END(node);
    if (changed)
      directory_set_dirty();
  
diff --cc src/or/relay.c
index cf53116,46e8522..28f940c
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@@ -751,10 -750,10 +752,10 @@@ connection_ap_process_end_not_open
               (tor_inet_aton(conn->socks_request->address, &in) &&
                !conn->chosen_exit_name))) {
            log_info(LD_APP,
-                  "Exitrouter '%s' seems to be more restrictive than its exit "
+                  "Exitrouter %s seems to be more restrictive than its exit "
                   "policy. Not using this router as exit for now.",
-                  node_get_nickname(exitrouter));
 -                 router_describe(exitrouter));
 -          policies_set_router_exitpolicy_to_reject_all(exitrouter);
++                 node_describe(exitrouter));
 +          policies_set_node_exitpolicy_to_reject_all(exitrouter);
          }
          /* rewrite it to an IP if we learned one. */
          if (addressmap_rewrite(conn->socks_request->address,
diff --cc src/or/rendservice.c
index 3d5c80c,edcf59d..fa81fb3
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@@ -1607,11 -1608,11 +1609,11 @@@ directory_post_to_hs_dir(rend_service_d
                                  hs_dir->identity_digest))
          /* Don't upload descriptor if we succeeded in doing so last time. */
          continue;
 -      if (!router_get_by_digest(hs_dir->identity_digest)) {
 +      if (!router_get_by_id_digest(hs_dir->identity_digest)) {
          log_info(LD_REND, "Not sending publish request for v2 descriptor to "
-                           "hidden service directory '%s'; we don't have its "
+                           "hidden service directory %s; we don't have its "
                            "router descriptor. Queuing for later upload.",
-                  hs_dir->nickname);
+                  safe_str_client(routerstatus_describe(hs_dir)));
          failed_upload = -1;
          continue;
        }
@@@ -1816,10 -1817,11 +1818,11 @@@ rend_services_introduce(void
         service. */
      for (j=0; j < smartlist_len(service->intro_nodes); ++j) {
        intro = smartlist_get(service->intro_nodes, j);
 -      router = router_get_by_digest(intro->extend_info->identity_digest);
 -      if (!router || !find_intro_circuit(intro, service->pk_digest)) {
 +      node = node_get_by_id(intro->extend_info->identity_digest);
 +      if (!node || !find_intro_circuit(intro, service->pk_digest)) {
          log_info(LD_REND,"Giving up on %s as intro point for %s.",
-                  intro->extend_info->nickname, service->service_id);
+                  safe_str_client(extend_info_describe(intro->extend_info)),
+                  safe_str_client(service->service_id));
          if (service->desc) {
            SMARTLIST_FOREACH(service->desc->intro_nodes, rend_intro_point_t *,
                              dintro, {
@@@ -1885,7 -1887,8 +1888,8 @@@
        tor_assert(!crypto_pk_generate_key(intro->intro_key));
        smartlist_add(service->intro_nodes, intro);
        log_info(LD_REND, "Picked router %s as an intro point for %s.",
-                node_get_nickname(node), service->service_id);
 -               safe_str_client(router_describe(router)),
++               safe_str_client(node_describe(node)),
+                safe_str_client(service->service_id));
      }
  
      /* If there's no need to launch new circuits, stop here. */
diff --cc src/or/router.c
index 2b11a52,874d234..73fabef
--- a/src/or/router.c
+++ b/src/or/router.c
@@@ -2235,6 -2224,142 +2235,186 @@@ is_legal_hexdigest(const char *s
            strspn(s,HEX_CHARACTERS)==HEX_DIGEST_LEN);
  }
  
+ /** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
+  * hold a human-readable description of a node with identity digest
+  * <b>id_digest</b>, named-status <b>is_named</b>, nickname <b>nickname</b>,
+  * and address <b>addr</b> or <b>addr32h</b>.
+  *
+  * The <b>nickname</b> and <b>addr</b> fields are optional and may be set to
+  * NULL.  The <b>addr32h</b> field is optional and may be set to 0.
+  *
+  * Return a pointer to the front of <b>buf</b>.
+  */
+ const char *
+ format_node_description(char *buf,
+                         const char *id_digest,
+                         int is_named,
+                         const char *nickname,
+                         const tor_addr_t *addr,
+                         uint32_t addr32h)
+ {
+   char *cp;
+ 
+   if (!buf)
+     return "<NULL BUFFER>";
+ 
+   buf[0] = '$';
+   base16_encode(buf+1, HEX_DIGEST_LEN+1, id_digest, DIGEST_LEN);
+   cp = buf+1+HEX_DIGEST_LEN;
+   if (nickname) {
+     buf[1+HEX_DIGEST_LEN] = is_named ? '=' : '~';
+     strlcpy(buf+1+HEX_DIGEST_LEN+1, nickname, MAX_NICKNAME_LEN+1);
+     cp += strlen(cp);
+   }
+   if (addr32h || addr) {
+     memcpy(cp, " at ", 4);
+     cp += 4;
+     if (addr) {
+       tor_addr_to_str(cp, addr, TOR_ADDR_BUF_LEN, 0);
+     } else {
+       struct in_addr in;
+       in.s_addr = htonl(addr32h);
+       tor_inet_ntoa(&in, cp, INET_NTOA_BUF_LEN);
+     }
+   }
+   return buf;
+ }
+ 
+ /** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
+  * hold a human-readable description of <b>ri</b>.
+  *
+  *
+  * Return a pointer to the front of <b>buf</b>.
+  */
+ const char *
+ router_get_description(char *buf, const routerinfo_t *ri)
+ {
+   if (!ri)
+     return "<null>";
+   return format_node_description(buf,
+                                  ri->cache_info.identity_digest,
 -                                 ri->is_named,
++                                 router_is_named(ri),
+                                  ri->nickname,
+                                  NULL,
+                                  ri->addr);
+ }
+ 
+ /** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
++ * hold a human-readable description of <b>node</b>.
++ *
++ * Return a pointer to the front of <b>buf</b>.
++ */
++const char *
++node_get_description(char *buf, const node_t *node)
++{
++  const char *nickname = NULL;
++  uint32_t addr32h = 0;
++  int is_named = 0;
++
++  if (!node)
++    return "<null>";
++
++  if (node->rs) {
++    nickname = node->rs->nickname;
++    is_named = node->rs->is_named;
++    addr32h = node->rs->addr;
++  } else if (node->ri) {
++    nickname = node->ri->nickname;
++    addr32h = node->ri->addr;
++  }
++
++  return format_node_description(buf,
++                                 node->identity,
++                                 is_named,
++                                 nickname,
++                                 NULL,
++                                 addr32h);
++}
++
++/** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
+  * hold a human-readable description of <b>rs</b>.
+  *
+  * Return a pointer to the front of <b>buf</b>.
+  */
+ const char *
+ routerstatus_get_description(char *buf, const routerstatus_t *rs)
+ {
+   if (!rs)
+     return "<null>";
+   return format_node_description(buf,
+                                  rs->identity_digest,
+                                  rs->is_named,
+                                  rs->nickname,
+                                  NULL,
+                                  rs->addr);
+ }
+ 
+ /** Use <b>buf</b> (which must be at least NODE_DESC_BUF_LEN bytes long) to
+  * hold a human-readable description of <b>ei</b>.
+  *
+  * Return a pointer to the front of <b>buf</b>.
+  */
+ const char *
+ extend_info_get_description(char *buf, const extend_info_t *ei)
+ {
+   if (!ei)
+     return "<null>";
+   return format_node_description(buf,
+                                  ei->identity_digest,
+                                  0,
+                                  ei->nickname,
+                                  &ei->addr,
+                                  0);
+ }
+ 
+ /** Return a human-readable description of the routerinfo_t <b>ri</b>.
+  *
+  * This function is not thread-safe.  Each call to this function invalidates
+  * previous values returned by this function.
+  */
+ const char *
+ router_describe(const routerinfo_t *ri)
+ {
+   static char buf[NODE_DESC_BUF_LEN];
+   return router_get_description(buf, ri);
+ }
+ 
++/** Return a human-readable description of the node_t <b>node</b>.
++ *
++ * This function is not thread-safe.  Each call to this function invalidates
++ * previous values returned by this function.
++ */
++const char *
++node_describe(const node_t *node)
++{
++  static char buf[NODE_DESC_BUF_LEN];
++  return node_get_description(buf, node);
++}
++
+ /** Return a human-readable description of the routerstatus_t <b>rs</b>.
+  *
+  * This function is not thread-safe.  Each call to this function invalidates
+  * previous values returned by this function.
+  */
+ const char *
+ routerstatus_describe(const routerstatus_t *rs)
+ {
+   static char buf[NODE_DESC_BUF_LEN];
+   return routerstatus_get_description(buf, rs);
+ }
+ 
+ /** Return a human-readable description of the extend_info_t <b>ri</b>.
+  *
+  * This function is not thread-safe.  Each call to this function invalidates
+  * previous values returned by this function.
+  */
+ const char *
+ extend_info_describe(const extend_info_t *ei)
+ {
+   static char buf[NODE_DESC_BUF_LEN];
+   return extend_info_get_description(buf, ei);
+ }
+ 
  /** Set <b>buf</b> (which must have MAX_VERBOSE_NICKNAME_LEN+1 bytes) to the
   * verbose representation of the identity of <b>router</b>.  The format is:
   *  A dollar sign.
diff --cc src/or/router.h
index 2e5d44f,a27c1d9..e208eb1
--- a/src/or/router.h
+++ b/src/or/router.h
@@@ -85,6 -85,28 +85,30 @@@ int extrainfo_dump_to_string(char **s, 
  int is_legal_nickname(const char *s);
  int is_legal_nickname_or_hexdigest(const char *s);
  int is_legal_hexdigest(const char *s);
+ 
+ /**
+  * Longest allowed output of format_node_description, plus 1 character for
+  * NUL.  This allows space for:
+  * "$FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF~xxxxxxxxxxxxxxxxxxx at"
+  * " [ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]"
+  * plus a terminating NUL.
+  */
+ #define NODE_DESC_BUF_LEN (MAX_VERBOSE_NICKNAME_LEN+4+TOR_ADDR_BUF_LEN)
+ const char *format_node_description(char *buf,
+                                     const char *id_digest,
+                                     int is_named,
+                                     const char *nickname,
+                                     const tor_addr_t *addr,
+                                     uint32_t addr32h);
+ const char *router_get_description(char *buf, const routerinfo_t *ri);
++const char *node_get_description(char *buf, const node_t *node);
+ const char *routerstatus_get_description(char *buf, const routerstatus_t *rs);
+ const char *extend_info_get_description(char *buf, const extend_info_t *ei);
+ const char *router_describe(const routerinfo_t *ri);
++const char *node_describe(const node_t *node);
+ const char *routerstatus_describe(const routerstatus_t *ri);
+ const char *extend_info_describe(const extend_info_t *ei);
+ 
  void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
  void routerstatus_get_verbose_nickname(char *buf,
                                         const routerstatus_t *router);
diff --cc src/or/routerlist.c
index 5ce50aa,47a57a8..a8a5974
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@@ -2280,19 -2265,9 +2280,19 @@@ hex_digest_nickname_matches(const char 
        return 0;
    }
  
 -  if (base16_decode(digest, DIGEST_LEN, hexdigest, HEX_DIGEST_LEN)<0)
 -    return 0;
 -  return (tor_memeq(digest, identity_digest, DIGEST_LEN));
 +  return tor_memeq(digest, identity_digest, DIGEST_LEN);
 +}
 +
 +/* Return true iff <b>router</b> is listed as named in the current
 + * consensus. */
- static int
++int
 +router_is_named(const routerinfo_t *router)
 +{
 +  const char *digest =
 +    networkstatus_get_router_digest_by_nickname(router->nickname);
 +
 +  return (digest &&
 +          tor_memeq(digest, router->cache_info.identity_digest, DIGEST_LEN));
  }
  
  /** Return true iff the digest of <b>router</b>'s identity key,
@@@ -3227,20 -3208,20 +3227,18 @@@ router_set_status(const char *digest, i
                      if (tor_memeq(d->digest, digest, DIGEST_LEN))
                        d->is_running = up);
  
 -  router = router_get_by_digest(digest);
 -  if (router) {
 +  node = node_get_mutable_by_id(digest);
 +  if (node) {
 +#if 0
-     char buf[MAX_VERBOSE_NICKNAME_LEN+1];
-     node_get_verbose_nickname(node,buf);
      log_debug(LD_DIR,"Marking router %s as %s.",
-               buf, up ? "up" : "down");
 -              router_describe(router), up ? "up" : "down");
 -    if (!up && router_is_me(router) && !we_are_hibernating())
++              node_describe(node), up ? "up" : "down");
 +#endif
 +    if (!up && node_is_me(node) && !we_are_hibernating())
        log_warn(LD_NET, "We just marked ourself as down. Are your external "
                 "addresses reachable?");
 -    router->is_running = up;
 -  }
 -  status = router_get_consensus_status_by_id(digest);
 -  if (status && status->is_running != up) {
 -    status->is_running = up;
 -    control_event_networkstatus_changed_single(status);
 +    node->is_running = up;
    }
 +
    router_dir_info_changed();
  }
  
diff --cc src/or/routerlist.h
index a613c34,fec1870..3a8af6f
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@@ -54,12 -57,13 +54,13 @@@ const node_t *router_choose_random_node
                                          struct routerset_t *excludedset,
                                          router_crn_flags_t flags);
  
 -routerinfo_t *router_get_by_nickname(const char *nickname,
 +const routerinfo_t *router_get_by_nickname(const char *nickname,
                                       int warn_if_unnamed);
 -int router_digest_version_as_new_as(const char *digest, const char *cutoff);
++int router_is_named(const routerinfo_t *router);
  int router_digest_is_trusted_dir_type(const char *digest,
 -                                      authority_type_t type);
 +                                      dirinfo_type_t type);
  #define router_digest_is_trusted_dir(d) \
 -  router_digest_is_trusted_dir_type((d), NO_AUTHORITY)
 +  router_digest_is_trusted_dir_type((d), NO_DIRINFO)
  
  int router_addr_is_trusted_dir(uint32_t addr);
  int hexdigest_to_digest(const char *hexdigest, char *digest);



More information about the tor-commits mailing list