[tor-commits] [tor/release-0.2.7] Check ORPort and DirPort reachability before publishing a relay descriptor

nickm at torproject.org nickm at torproject.org
Mon Mar 21 14:52:21 UTC 2016


commit 6094a886cf9be92d29077b428554a75c9971a2ca
Author: teor (Tim Wilson-Brown) <teor2345 at gmail.com>
Date:   Mon Jan 18 14:00:29 2016 +1100

    Check ORPort and DirPort reachability before publishing a relay descriptor
    
    Otherwise, relays publish a descriptor with DirPort 0 when the DirPort
    reachability test takes longer than the ORPort reachability test.
    
    Closes bug #18050. Reported by "starlight", patch by "teor".
    Bugfix on 0.1.0.1-rc, commit a1f1fa6ab on 27 Feb 2005.
---
 changes/bug18050 |  7 +++++++
 src/or/main.c    | 10 ++++++----
 src/or/router.c  | 13 +++++++++----
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/changes/bug18050 b/changes/bug18050
new file mode 100644
index 0000000..ce24a77
--- /dev/null
+++ b/changes/bug18050
@@ -0,0 +1,7 @@
+  o Minor fixes (relays):
+    - Check that both the ORPort and DirPort (if present) are reachable
+      before publishing a relay descriptor. Otherwise, relays publish a
+      descriptor with DirPort 0 when the DirPort reachability test takes
+      longer than the ORPort reachability test.
+      Closes bug #18050. Reported by "starlight", patch by "teor".
+      Bugfix on 0.1.0.1-rc, commit a1f1fa6ab on 27 Feb 2005.
diff --git a/src/or/main.c b/src/or/main.c
index df0cd1b..5198b51 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1718,8 +1718,9 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg)
     if (me && !check_whether_orport_reachable()) {
       char *address = tor_dup_ip(me->addr);
       log_warn(LD_CONFIG,"Your server (%s:%d) has not managed to confirm that "
-               "its ORPort is reachable. Please check your firewalls, ports, "
-               "address, /etc/hosts file, etc.",
+               "its ORPort is reachable. Relays do not publish descriptors "
+               "until their ORPort and DirPort are reachable. Please check "
+               "your firewalls, ports, address, /etc/hosts file, etc.",
                address, me->or_port);
       control_event_server_status(LOG_WARN,
                                   "REACHABILITY_FAILED ORADDRESS=%s:%d",
@@ -1731,8 +1732,9 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg)
       char *address = tor_dup_ip(me->addr);
       log_warn(LD_CONFIG,
                "Your server (%s:%d) has not managed to confirm that its "
-               "DirPort is reachable. Please check your firewalls, ports, "
-               "address, /etc/hosts file, etc.",
+               "DirPort is reachable. Relays do not publish descriptors "
+               "until their ORPort and DirPort are reachable. Please check "
+               "your firewalls, ports, address, /etc/hosts file, etc.",
                address, me->dir_port);
       control_event_server_status(LOG_WARN,
                                   "REACHABILITY_FAILED DIRADDRESS=%s:%d",
diff --git a/src/or/router.c b/src/or/router.c
index 2ddaa89..53e0522 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1232,7 +1232,8 @@ router_orport_found_reachable(void)
     char *address = tor_dup_ip(me->addr);
     log_notice(LD_OR,"Self-testing indicates your ORPort is reachable from "
                "the outside. Excellent.%s",
-               get_options()->PublishServerDescriptor_ != NO_DIRINFO ?
+               get_options()->PublishServerDescriptor_ != NO_DIRINFO
+               && check_whether_dirport_reachable() ?
                  " Publishing server descriptor." : "");
     can_reach_or_port = 1;
     mark_my_descriptor_dirty("ORPort found reachable");
@@ -1256,7 +1257,10 @@ router_dirport_found_reachable(void)
   if (!can_reach_dir_port && me) {
     char *address = tor_dup_ip(me->addr);
     log_notice(LD_DIRSERV,"Self-testing indicates your DirPort is reachable "
-               "from the outside. Excellent.");
+               "from the outside. Excellent.%s",
+               get_options()->PublishServerDescriptor_ != NO_DIRINFO
+               && check_whether_orport_reachable() ?
+               " Publishing server descriptor." : "");
     can_reach_dir_port = 1;
     if (decide_to_advertise_dirport(get_options(), me->dir_port)) {
       mark_my_descriptor_dirty("DirPort found reachable");
@@ -1459,7 +1463,8 @@ proxy_mode(const or_options_t *options)
  * and
  * - We have ORPort set
  * and
- * - We believe we are reachable from the outside; or
+ * - We believe both our ORPort and DirPort (if present) are reachable from
+ *   the outside; or
  * - We are an authoritative directory server.
  */
 static int
@@ -1478,7 +1483,7 @@ decide_if_publishable_server(void)
   if (!router_get_advertised_or_port(options))
     return 0;
 
-  return check_whether_orport_reachable();
+  return check_whether_orport_reachable() && check_whether_dirport_reachable();
 }
 
 /** Initiate server descriptor upload as reasonable (if server is publishable,





More information about the tor-commits mailing list