[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] routerlist: Choose bridges for direct bridge connections



commit 73ace125a972c421287503738e9599f411193e1a
Author: teor <teor@xxxxxxxxxx>
Date:   Wed May 13 13:47:52 2020 +1000

    routerlist: Choose bridges for direct bridge connections
    
    When counting and choosing nodes on a client that uses bridges, only
    choose bridges for direct connections.
    
    Part of 34200.
---
 src/feature/nodelist/routerlist.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/feature/nodelist/routerlist.c b/src/feature/nodelist/routerlist.c
index f606e3c18..ece3379fa 100644
--- a/src/feature/nodelist/routerlist.c
+++ b/src/feature/nodelist/routerlist.c
@@ -516,11 +516,19 @@ routers_have_same_or_addrs(const routerinfo_t *r1, const routerinfo_t *r2)
  * The following conditions are applied to all nodes:
  *  - is running;
  *  - is valid;
- *  - has a general-purpose routerinfo;
  *  - supports EXTEND2 cells;
  *  - has an ntor circuit crypto key; and
  *  - does not allow single-hop exits.
  *
+ * If the node has a routerinfo, we're checking for a direct connection, and
+ * we're using bridges, the following condition is applied:
+ *  - has a bridge-purpose routerinfo;
+ * and for all other nodes:
+ *  - has a general-purpose routerinfo (or no routerinfo).
+ *
+ * Nodes that don't have a routerinfo must be general-purpose nodes, because
+ * routerstatuses and microdescriptors only come via consensuses.
+ *
  * The <b>flags</b> chech that <b>node</b>:
  *  - <b>CRN_NEED_UPTIME</b>: has more than a minimum uptime;
  *  - <b>CRN_NEED_CAPACITY</b>: has more than a minimum capacity;
@@ -550,16 +558,21 @@ router_can_choose_node(const node_t *node, int flags)
   const bool rendezvous_v3 = (flags & CRN_RENDEZVOUS_V3) != 0;
   const bool initiate_ipv6_extend = (flags & CRN_INITIATE_IPV6_EXTEND) != 0;
 
+  const or_options_t *options = get_options();
   const bool check_reach =
-    !router_or_conn_should_skip_reachable_address_check(get_options(),
-                                                        pref_addr);
+    !router_or_conn_should_skip_reachable_address_check(options, pref_addr);
+  const bool direct_bridge = direct_conn && options->UseBridges;
 
   if (!node->is_running || !node->is_valid)
     return false;
   if (need_desc && !node_has_preferred_descriptor(node, direct_conn))
     return false;
-  if (node->ri && node->ri->purpose != ROUTER_PURPOSE_GENERAL)
-    return false;
+  if (node->ri) {
+    if (direct_bridge && node->ri->purpose != ROUTER_PURPOSE_BRIDGE)
+      return false;
+    else if (node->ri->purpose != ROUTER_PURPOSE_GENERAL)
+      return false;
+  }
   if (node_is_unreliable(node, need_uptime, need_capacity, need_guard))
     return false;
   /* Don't choose nodes if we are certain they can't do EXTEND2 cells */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits