]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
New ReconfigDropsBridgeDescs config option
authorRoger Dingledine <arma@torproject.org>
Mon, 25 Jan 2021 07:16:44 +0000 (02:16 -0500)
committerRoger Dingledine <arma@torproject.org>
Mon, 25 Jan 2021 07:16:44 +0000 (02:16 -0500)
Let external bridge reachability testing tools discard cached
bridge descriptors when setting new bridges, so they can be sure
to get a clean reachability test.

Implements ticket 40209.

changes/ticket40209 [new file with mode: 0644]
src/app/config/config.c
src/app/config/or_options_st.h
src/feature/nodelist/routerlist.c
src/feature/nodelist/routerlist.h

diff --git a/changes/ticket40209 b/changes/ticket40209
new file mode 100644 (file)
index 0000000..a90243b
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor features (bridge testing support):
+    - Let external bridge reachability testing tools discard cached
+      bridge descriptors when setting new bridges, so they can be sure
+      to get a clean reachability test. Implements ticket 40209.
index c7799ec1a2b780db2f210444ac685a3c4a469eae..79629a24655939b82a89fd698024e0c6572e9ad2 100644 (file)
@@ -628,6 +628,7 @@ static const config_var_t option_vars_[] = {
   V(ConnectionPadding,           AUTOBOOL, "auto"),
   V(RefuseUnknownExits,          AUTOBOOL, "auto"),
   V(CircuitPadding,              BOOL,     "1"),
+  V(ReconfigDropsBridgeDescs,    BOOL,     "0"),
   V(ReducedCircuitPadding,       BOOL,     "0"),
   V(RejectPlaintextPorts,        CSV,      ""),
   V(RelayBandwidthBurst,         MEMUNIT,  "0"),
@@ -2321,6 +2322,8 @@ options_act,(const or_options_t *old_options))
     }
 
     if (transition_affects_guards) {
+      if (options->ReconfigDropsBridgeDescs)
+        routerlist_drop_bridge_descriptors();
       if (guards_update_all()) {
         abandon_circuits = 1;
       }
index 4364f145ed488d6837ee86e790575af6427ad1c6..d3488afa5cf467cd90bb45eb65c1e2e2c51497ed 100644 (file)
@@ -293,6 +293,13 @@ struct or_options_t {
    * disabled. */
   int CircuitPadding;
 
+  /** Boolean: if true, then this client will discard cached bridge
+   * descriptors on a setconf or other config change that impacts guards
+   * or bridges (see options_transition_affects_guards() for exactly which
+   * config changes trigger it). Useful for tools that test bridge
+   * reachability by fetching fresh descriptors. */
+  int ReconfigDropsBridgeDescs;
+
   /** Boolean: if true, then this client will only use circuit padding
    * algorithms that are known to use a low amount of overhead. If false,
    * we will use all available circuit padding algorithms.
index a1a348edb934fc65849ab9cc2066844823ad94d4..67f4a4546afd6036f2ee3bec6544e6d3e4e8fc24 100644 (file)
@@ -2012,6 +2012,30 @@ routerlist_remove_old_routers(void)
   router_rebuild_store(RRS_DONT_REMOVE_OLD,&routerlist->extrainfo_store);
 }
 
+/* Drop every bridge descriptor in our routerlist. Used by the external
+ * 'bridgestrap' tool to discard bridge descriptors so that it can then
+ * do a clean reachability test. */
+void
+routerlist_drop_bridge_descriptors(void)
+{
+  routerinfo_t *router;
+  int i;
+
+  if (!routerlist)
+    return;
+
+  for (i = 0; i < smartlist_len(routerlist->routers); ++i) {
+    router = smartlist_get(routerlist->routers, i);
+    if (router->purpose == ROUTER_PURPOSE_BRIDGE) {
+      log_notice(LD_DIR,
+               "Dropping existing bridge descriptor for %s",
+               router_describe(router));
+      routerlist_remove(routerlist, router, 0, time(NULL));
+      i--;
+    }
+  }
+}
+
 /** We just added a new set of descriptors. Take whatever extra steps
  * we need. */
 void
index 98472b27718d0482a52e29a3dc2fbb17885fed51..f72fdfc11716665db67e86c8b9e4ab3227634963 100644 (file)
@@ -145,6 +145,7 @@ was_router_added_t router_add_extrainfo_to_routerlist(
                                         int from_cache, int from_fetch);
 void routerlist_descriptors_added(smartlist_t *sl, int from_cache);
 void routerlist_remove_old_routers(void);
+void routerlist_drop_bridge_descriptors(void);
 int router_load_single_router(const char *s, uint8_t purpose, int cache,
                               const char **msg);
 int router_load_routers_from_string(const char *s, const char *eos,