[tor-commits] [tor/master] relay: Move inform_testing_rechability() to relay

nickm at torproject.org nickm at torproject.org
Thu Apr 9 15:56:21 UTC 2020


commit fdba6ff0c0f27b9948101e63efd5acb965a2f6a3
Author: teor <teor at torproject.org>
Date:   Tue Mar 17 16:16:05 2020 +1000

    relay: Move inform_testing_rechability() to relay
    
    Move inform_testing_rechability() to the relay module, and disable it
    when the relay module is disabled.
    
    Part of 33633.
---
 src/core/or/circuitbuild.c       | 34 ----------------------------------
 src/core/or/circuitbuild.h       |  1 -
 src/feature/relay/relay_config.c |  2 +-
 src/feature/relay/selftest.c     | 34 ++++++++++++++++++++++++++++++++++
 src/feature/relay/selftest.h     |  7 +++++++
 5 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c
index 003b91af8..ea51d7b9b 100644
--- a/src/core/or/circuitbuild.c
+++ b/src/core/or/circuitbuild.c
@@ -767,40 +767,6 @@ circuit_deliver_create_cell(circuit_t *circ, const create_cell_t *create_cell,
   return -1;
 }
 
-/** We've decided to start our reachability testing. If all
- * is set, log this to the user. Return 1 if we did, or 0 if
- * we chose not to log anything. */
-int
-inform_testing_reachability(void)
-{
-  char dirbuf[128];
-  char *address;
-  const routerinfo_t *me = router_get_my_routerinfo();
-  if (!me)
-    return 0;
-  address = tor_dup_ip(me->addr);
-  control_event_server_status(LOG_NOTICE,
-                              "CHECKING_REACHABILITY ORADDRESS=%s:%d",
-                              address, me->or_port);
-  if (me->dir_port) {
-    tor_snprintf(dirbuf, sizeof(dirbuf), " and DirPort %s:%d",
-                 address, me->dir_port);
-    control_event_server_status(LOG_NOTICE,
-                                "CHECKING_REACHABILITY DIRADDRESS=%s:%d",
-                                address, me->dir_port);
-  }
-  log_notice(LD_OR, "Now checking whether ORPort %s:%d%s %s reachable... "
-                         "(this may take up to %d minutes -- look for log "
-                         "messages indicating success)",
-      address, me->or_port,
-      me->dir_port ? dirbuf : "",
-      me->dir_port ? "are" : "is",
-      TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT/60);
-
-  tor_free(address);
-  return 1;
-}
-
 /** Return true iff we should send a create_fast cell to start building a given
  * circuit */
 static inline int
diff --git a/src/core/or/circuitbuild.h b/src/core/or/circuitbuild.h
index 48592dd34..9a35c36ac 100644
--- a/src/core/or/circuitbuild.h
+++ b/src/core/or/circuitbuild.h
@@ -29,7 +29,6 @@ struct circuit_guard_state_t *origin_circuit_get_guard_state(
 int circuit_handle_first_hop(origin_circuit_t *circ);
 void circuit_n_chan_done(channel_t *chan, int status,
                          int close_origin_circuits);
-int inform_testing_reachability(void);
 int circuit_timeout_want_to_count_circ(const origin_circuit_t *circ);
 int circuit_send_next_onion_skin(origin_circuit_t *circ);
 void circuit_note_clock_jumped(int64_t seconds_elapsed, bool was_idle);
diff --git a/src/feature/relay/relay_config.c b/src/feature/relay/relay_config.c
index c8b40ae05..50cdde5dd 100644
--- a/src/feature/relay/relay_config.c
+++ b/src/feature/relay/relay_config.c
@@ -29,7 +29,6 @@
 #include "core/mainloop/connection.h"
 #include "core/mainloop/cpuworker.h"
 #include "core/mainloop/mainloop.h"
-#include "core/or/circuitbuild.h"
 #include "core/or/connection_or.h"
 #include "core/or/port_cfg_st.h"
 
@@ -44,6 +43,7 @@
 #include "feature/dircache/consdiffmgr.h"
 #include "feature/relay/dns.h"
 #include "feature/relay/routermode.h"
+#include "feature/relay/selftest.h"
 
 /** Contents of most recently read DirPortFrontPage file. */
 static char *global_dirfrontpagecontents = NULL;
diff --git a/src/feature/relay/selftest.c b/src/feature/relay/selftest.c
index 29febdee8..8aaf068f9 100644
--- a/src/feature/relay/selftest.c
+++ b/src/feature/relay/selftest.c
@@ -213,6 +213,40 @@ router_do_reachability_checks(int test_or, int test_dir)
   }
 }
 
+/** We've decided to start our reachability testing. If all
+ * is set, log this to the user. Return 1 if we did, or 0 if
+ * we chose not to log anything. */
+int
+inform_testing_reachability(void)
+{
+  char dirbuf[128];
+  char *address;
+  const routerinfo_t *me = router_get_my_routerinfo();
+  if (!me)
+    return 0;
+  address = tor_dup_ip(me->addr);
+  control_event_server_status(LOG_NOTICE,
+                              "CHECKING_REACHABILITY ORADDRESS=%s:%d",
+                              address, me->or_port);
+  if (me->dir_port) {
+    tor_snprintf(dirbuf, sizeof(dirbuf), " and DirPort %s:%d",
+                 address, me->dir_port);
+    control_event_server_status(LOG_NOTICE,
+                                "CHECKING_REACHABILITY DIRADDRESS=%s:%d",
+                                address, me->dir_port);
+  }
+  log_notice(LD_OR, "Now checking whether ORPort %s:%d%s %s reachable... "
+                         "(this may take up to %d minutes -- look for log "
+                         "messages indicating success)",
+      address, me->or_port,
+      me->dir_port ? dirbuf : "",
+      me->dir_port ? "are" : "is",
+      TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT/60);
+
+  tor_free(address);
+  return 1;
+}
+
 /** Annotate that we found our ORPort reachable. */
 void
 router_orport_found_reachable(void)
diff --git a/src/feature/relay/selftest.h b/src/feature/relay/selftest.h
index ffe06eda6..f5babc95d 100644
--- a/src/feature/relay/selftest.h
+++ b/src/feature/relay/selftest.h
@@ -20,6 +20,7 @@ int check_whether_dirport_reachable(const struct or_options_t *options);
 
 void router_do_reachability_checks(int test_or, int test_dir);
 void router_perform_bandwidth_test(int num_circs, time_t now);
+int inform_testing_reachability(void);
 
 void router_orport_found_reachable(void);
 void router_dirport_found_reachable(void);
@@ -47,6 +48,12 @@ router_perform_bandwidth_test(int num_circs, time_t now)
   (void)now;
   tor_assert_nonfatal_unreached();
 }
+static inline int
+inform_testing_reachability(void)
+{
+  tor_assert_nonfatal_unreached();
+  return 0;
+}
 
 #define router_orport_found_reachable() \
   STMT_NIL





More information about the tor-commits mailing list