commit 0f45dbefed1ddca4772bf66afb268bc20aefa1d1 Author: Linus Nordberg linus@torproject.org Date: Fri Aug 31 23:02:19 2012 +0200
Use preferred OR for nodes with routerstatus and microdesc too.
extend_info_from_node() used to use the primary OR port (i.e. IPv4) unless the node had routerinfo. Now that we have IPv6 addresses in microdescs we may want to use them.
Note that this patch changes using r->cache_info.identity_digest into using node->identity. I count on these being well synchronised, or things would break in other ways. Right? --- src/or/circuitbuild.c | 40 ++++++++++++++++++++++++---------------- 1 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 3419768..2a449b0 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -3872,26 +3872,34 @@ extend_info_alloc(const char *nickname, const char *digest, extend_info_t * extend_info_from_node(const node_t *node, int for_direct_connect) { - if (node->ri) { - const routerinfo_t *r = node->ri; - tor_addr_port_t ap; - if (for_direct_connect) - node_get_pref_orport(node, &ap); - else - node_get_prim_orport(node, &ap); - return extend_info_alloc(r->nickname, r->cache_info.identity_digest, - r->onion_pkey, &ap.addr, ap.port); - } else if (node->rs && node->md) { - tor_addr_t addr; - tor_addr_from_ipv4h(&addr, node->rs->addr); + tor_addr_port_t ap; + + if (node->ri == NULL && (node->rs == NULL || node->md == NULL)) + return NULL; + + if (for_direct_connect) + node_get_pref_orport(node, &ap); + else + node_get_prim_orport(node, &ap); + + log_debug(LD_CIRC, "using %s:%d for %s", + fmt_and_decorate_addr(&ap.addr), ap.port, + node->ri ? node->ri->nickname : node->rs->nickname); + + if (node->ri) + return extend_info_alloc(node->ri->nickname, + node->identity, + node->ri->onion_pkey, + &ap.addr, + ap.port); + else if (node->rs && node->md) return extend_info_alloc(node->rs->nickname, node->identity, node->md->onion_pkey, - &addr, - node->rs->or_port); - } else { + &ap.addr, + ap.port); + else return NULL; - } }
/** Release storage held by an extend_info_t struct. */