aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@torproject.org>2012-08-27 15:03:34 +0200
committerNick Mathewson <nickm@torproject.org>2012-09-04 12:57:21 -0400
commite04e1a2e7d67861881c9e237dcea344dda39e858 (patch)
treee5ca5d75af523b6bf1a93fd027a70b2bf4b186f4 /src/or/circuitbuild.c
parentd6ad00a01f703a79d9ca6d6edd958b4d05279b4e (diff)
downloadtor-e04e1a2e7d67861881c9e237dcea344dda39e858.tar
tor-e04e1a2e7d67861881c9e237dcea344dda39e858.tar.gz
Clients connect to public relays over IPv6.
Add ClientUseIPv6 and ClientPreferIPv6ORPort configuration options. Use "preferred OR port" for all entry nodes, not only for bridges. Mark bridges with "prefer IPv6 OR port" if an IPv6 address is configured in Bridge line and ClientPreferIPv6ORPort is set. Mark relays with "prefer IPv6 OR port" if an IPv6 address is found in descriptor and ClientPreferIPv6ORPort is set. Filter "preferred OR port" through the ClientUseIPv6 config option. We might want to move this test to where actual connection is being set up once we have a fall back mechanism in place. Have only non-servers pick an IPv6 address for the first hop: We don't want relays to connect over IPv6 yet. (IPv6 has never been used for second or third hops.) Implements ticket 5535.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index ba617ffa4..34197680b 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -3792,12 +3792,10 @@ onion_extend_cpath(origin_circuit_t *circ)
} else if (cur_len == 0) { /* picking first node */
const node_t *r = choose_good_entry_server(purpose, state);
if (r) {
- /* If we're extending to a bridge, use the preferred address
- rather than the primary, for potentially extending to an IPv6
- bridge. */
- int use_pref_addr = (r->ri != NULL &&
- r->ri->purpose == ROUTER_PURPOSE_BRIDGE);
- info = extend_info_from_node(r, use_pref_addr);
+ /* If we're a client, use the preferred address rather than the
+ primary address, for potentially connecting to an IPv6 OR
+ port. */
+ info = extend_info_from_node(r, server_mode(get_options()) == 0);
tor_assert(info);
}
} else {
@@ -3865,10 +3863,11 @@ extend_info_alloc(const char *nickname, const char *digest,
/** Allocate and return a new extend_info that can be used to build a
* circuit to or through the node <b>node</b>. Use the primary address
- * of the node unless <b>for_direct_connect</b> is true, in which case
- * the preferred address is used instead. May return NULL if there is
- * not enough info about <b>node</b> to extend to it--for example, if
- * there is no routerinfo_t or microdesc_t.
+ * of the node (i.e. its IPv4 address) unless
+ * <b>for_direct_connect</b> is true, in which case the preferred
+ * address is used instead. May return NULL if there is not enough
+ * info about <b>node</b> to extend to it--for example, if there is no
+ * routerinfo_t or microdesc_t.
**/
extend_info_t *
extend_info_from_node(const node_t *node, int for_direct_connect)
@@ -5607,10 +5606,15 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node)
}
}
- /* Indicate that we prefer connecting to this bridge over the
- protocol that the bridge address indicates. Last bridge
- descriptor handled wins. */
- node->ipv6_preferred = tor_addr_family(&bridge->addr) == AF_INET6;
+ /* Mark bridge as preferably connected to over IPv6 if its IPv6
+ address is in a Bridge line and ClientPreferIPv6ORPort is
+ set. Unless both is true, a potential IPv6 OR port of this
+ bridge won't get selected.
+
+ XXX ipv6_preferred is never reset (#6757) */
+ if (get_options()->ClientPreferIPv6ORPort == 1 &&
+ tor_addr_family(&bridge->addr) == AF_INET6)
+ node->ipv6_preferred = 1;
/* XXXipv6 we lack support for falling back to another address for
the same relay, warn the user */