[tor-commits] [tor/master] relay: Log IPv4 and IPv6 ORPorts when testing reachability

nickm at torproject.org nickm at torproject.org
Tue Jun 9 19:45:23 UTC 2020


commit aade9f31e7a578a78d359be65f5a3805801bf329
Author: teor <teor at torproject.org>
Date:   Thu Apr 30 22:30:02 2020 +1000

    relay: Log IPv4 and IPv6 ORPorts when testing reachability
    
    When a relay starts testing reachability, log its IPv6 ORPort.
    The existing code logs the IPv4 ORPort and DirPort.
    
    The IPv4 ORPort is required. The other ports are only logged if they
    are present.
    
    Part of 33222.
---
 src/feature/relay/selftest.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/feature/relay/selftest.c b/src/feature/relay/selftest.c
index 939fc90c8..d19eb00d4 100644
--- a/src/feature/relay/selftest.c
+++ b/src/feature/relay/selftest.c
@@ -272,7 +272,7 @@ router_do_reachability_checks(int test_or, int test_dir)
 int
 inform_testing_reachability(void)
 {
-  char dirbuf[128];
+  char extra_addrbuf[128];
   char *address;
   const routerinfo_t *me = router_get_my_routerinfo();
   if (!me)
@@ -281,20 +281,28 @@ inform_testing_reachability(void)
   control_event_server_status(LOG_NOTICE,
                               "CHECKING_REACHABILITY ORADDRESS=%s:%d",
                               address, me->or_port);
+  const bool has_ipv6 = tor_addr_port_is_valid(&me->ipv6_addr,
+                                               me->ipv6_orport, 0);
+  if (has_ipv6) {
+    tor_snprintf(extra_addrbuf, sizeof(extra_addrbuf), " and %s",
+                 fmt_addrport(&me->ipv6_addr, me->ipv6_orport));
+    /* We'll add an IPv6 control event in #34068. */
+  }
   if (me->dir_port) {
-    tor_snprintf(dirbuf, sizeof(dirbuf), " and DirPort %s:%d",
+    tor_snprintf(extra_addrbuf, sizeof(extra_addrbuf), " 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... "
+  log_notice(LD_OR, "Now checking whether ORPort%s %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);
+             has_ipv6 ? "s" : "",
+             address, me->or_port,
+             has_ipv6 || me->dir_port ? extra_addrbuf : "",
+             has_ipv6 || me->dir_port ? "are" : "is",
+             TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT/60);
 
   tor_free(address);
   return 1;





More information about the tor-commits mailing list