[tor-commits] [tor/master] Fix broken directory request to the DirPort

nickm at torproject.org nickm at torproject.org
Thu Mar 24 19:03:55 UTC 2016


commit ba6509e9e1f9bfd052ea8bdfef104c87ee8ca6b9
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Thu Mar 24 13:57:53 2016 -0400

    Fix broken directory request to the DirPort
    
    Commit e72cbf7a4 introduced a change to directory_initiate_command_rend()
    that made tor use the ORPort when making a directory request to the DirPort.
    The primary consequence was that a relay couldn't selftest its DirPort thus
    failing to work and join the network properly.
    
    The main issue was we were always considering an anonymized connection to be
    an OR connection which is not true.
    
    Fixes #18623
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/or/directory.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index 21a879d..d057dac 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1065,8 +1065,16 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port,
   const int use_begindir = directory_command_should_use_begindir(options,
                                      &or_addr_port->addr, or_addr_port->port,
                                      router_purpose, indirection);
+  /* Is it an anonymous connection? Be careful, it could be either an OR or
+   * directory connection. */
   const int anonymized_connection = dirind_is_anon(indirection);
-  const int or_connection = use_begindir || anonymized_connection;
+  /* Is it a connection to our DirPort? */
+  const int dir_connection = (indirection == DIRIND_ANON_DIRPORT ||
+                              indirection == DIRIND_DIRECT_CONN);
+  /* It's an OR connection if we should use BEGIN_DIR or if it's an
+   * anonymized connection but obviously not a directory connection. */
+  const int or_connection = (use_begindir ||
+                             (anonymized_connection && !dir_connection));
 
   tor_addr_t addr;
   tor_addr_copy(&addr, &(or_connection ? or_addr_port : dir_addr_port)->addr);
@@ -1096,7 +1104,7 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port,
 
   /* ensure that we don't make direct connections when a SOCKS server is
    * configured. */
-  if (!or_connection && !options->HTTPProxy &&
+  if (dir_connection && !options->HTTPProxy &&
       (options->Socks4Proxy || options->Socks5Proxy)) {
     log_warn(LD_DIR, "Cannot connect to a directory server through a "
                      "SOCKS proxy!");
@@ -1113,7 +1121,7 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port,
       logged_backtrace = 1;
     }
     return;
-  } else if (!or_connection && (!dir_addr_port->port
+  } else if (dir_connection && (!dir_addr_port->port
                                 || tor_addr_is_null(&dir_addr_port->addr))) {
     static int logged_backtrace = 0;
     log_warn(LD_DIR, "Cannot make an outgoing Dir connection without a Dir "
@@ -1153,7 +1161,7 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port,
   if (rend_query)
     conn->rend_data = rend_data_dup(rend_query);
 
-  if (!or_connection) {
+  if (dir_connection && !anonymized_connection) {
     /* then we want to connect to dirport directly */
 
     if (options->HTTPProxy) {





More information about the tor-commits mailing list