commit 525c1c493ea2bcab724919c1f2b3117c5db870f6 Author: Fernando Fernandez Mancera <ffernandezmanc...@gmail.com> Date: Tue Jan 2 15:28:15 2018 +0100
Set IPv6 preferences for bridges even if there is no ri. Tor now sets IPv6 preferences on rewrite_node_address_for_bridge() even if there is only ri or rs. It always warns about them. Also Tor now sets the IPv6 address in rs as well as it sets the one in ri. Fixes #24572 on 9e9edf7 in 0.2.4.5-alpha. Fixes #24573 on c213f27 in 0.2.8.2-alpha. Signed-off-by: Fernando Fernandez Mancera <ffernandezmanc...@gmail.com> --- changes/ticket24573 | 7 +++++++ src/or/bridges.c | 59 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/changes/ticket24573 b/changes/ticket24573 new file mode 100644 index 000000000..3026c1a12 --- /dev/null +++ b/changes/ticket24573 @@ -0,0 +1,7 @@ + o Minor bugfixes (IPv6 preferences on bridges): + - Tor now always sets IPv6 preferences for bridges, even if there is only + router information or router status and warns about them. Fixes bug + 24573; bugfix on c213f277cde in 0.2.8.2-alpha. + - Tor now sets IPv6 address in rs as well as it's set the one in ri. Closes + ticket 24572; bugfix on 9e9edf71f7d in 0.2.4.5-alpha. + Patch by "ffmancera". diff --git a/src/or/bridges.c b/src/or/bridges.c index 0b1bbbd15..204ff2684 100644 --- a/src/or/bridges.c +++ b/src/or/bridges.c @@ -716,7 +716,6 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node) if (node->ri) { routerinfo_t *ri = node->ri; tor_addr_from_ipv4h(&addr, ri->addr); - if ((!tor_addr_compare(&bridge->addr, &addr, CMP_EXACT) && bridge->port == ri->or_port) || (!tor_addr_compare(&bridge->addr, &ri->ipv6_addr, CMP_EXACT) && @@ -774,16 +773,58 @@ rewrite_node_address_for_bridge(const bridge_info_t *bridge, node_t *node) routerstatus_t *rs = node->rs; tor_addr_from_ipv4h(&addr, rs->addr); - if (!tor_addr_compare(&bridge->addr, &addr, CMP_EXACT) && - bridge->port == rs->or_port) { + if ((!tor_addr_compare(&bridge->addr, &addr, CMP_EXACT) && + bridge->port == rs->or_port) || + (!tor_addr_compare(&bridge->addr, &rs->ipv6_addr, CMP_EXACT) && + bridge->port == rs->ipv6_orport)) { /* they match, so no need to do anything */ } else { - rs->addr = tor_addr_to_ipv4h(&bridge->addr); - rs->or_port = bridge->port; - log_info(LD_DIR, - "Adjusted bridge routerstatus for '%s' to match " - "configured address %s.", - rs->nickname, fmt_addrport(&bridge->addr, rs->or_port)); + if (tor_addr_family(&bridge->addr) == AF_INET) { + rs->addr = tor_addr_to_ipv4h(&bridge->addr); + rs->or_port = bridge->port; + log_info(LD_DIR, + "Adjusted bridge routerstatus for '%s' to match " + "configured address %s.", + rs->nickname, fmt_addrport(&bridge->addr, rs->or_port)); + /* set IPv6 preferences even if there is no ri */ + } else if (tor_addr_family(&bridge->addr) == AF_INET6) { + tor_addr_copy(&rs->ipv6_addr, &bridge->addr); + rs->ipv6_orport = bridge->port; + log_info(LD_DIR, + "Adjusted bridge routerstatus for '%s' to match configured" + " address %s.", + rs->nickname, fmt_addrport(&rs->ipv6_addr, rs->ipv6_orport)); + } else { + log_err(LD_BUG, "Address family not supported: %d.", + tor_addr_family(&bridge->addr)); + return; + } + } + + if (options->ClientPreferIPv6ORPort == -1) { + /* Mark which address to use based on which bridge_t we got. */ + node->ipv6_preferred = (tor_addr_family(&bridge->addr) == AF_INET6 && + !tor_addr_is_null(&node->rs->ipv6_addr)); + } else { + /* Mark which address to use based on user preference */ + node->ipv6_preferred = (fascist_firewall_prefer_ipv6_orport(options) && + !tor_addr_is_null(&node->rs->ipv6_addr)); + } + + /* XXXipv6 we lack support for falling back to another address for + the same relay, warn the user */ + if (!tor_addr_is_null(&rs->ipv6_addr)) { + tor_addr_port_t ap; + node_get_pref_orport(node, &ap); + log_notice(LD_CONFIG, + "Bridge '%s' has both an IPv4 and an IPv6 address. " + "Will prefer using its %s address (%s) based on %s.", + rs->nickname, + node->ipv6_preferred ? "IPv6" : "IPv4", + fmt_addrport(&ap.addr, ap.port), + options->ClientPreferIPv6ORPort == -1 ? + "the configured Bridge address" : + "ClientPreferIPv6ORPort"); } } } _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits