diff options
author | Linus Nordberg <linus@torproject.org> | 2012-08-31 23:02:19 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-09-04 12:57:21 -0400 |
commit | 0f45dbefed1ddca4772bf66afb268bc20aefa1d1 (patch) | |
tree | a369cb7f62e55eb6e7b93959690b07669026904a | |
parent | 7a8366a3eb7081c29cbc0ebf0e9757cbfd71a86d (diff) | |
download | tor-0f45dbefed1ddca4772bf66afb268bc20aefa1d1.tar.gz tor-0f45dbefed1ddca4772bf66afb268bc20aefa1d1.zip |
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?
-rw-r--r-- | 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 34197680b1..2a449b0cc0 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. */ |