[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/maint-0.3.0] Allow relays to use directory mirrors without a DirPort



commit 18f47bbb73ce4039c67b6c5e87ea43126713d7dd
Author: teor <teor2345@xxxxxxxxx>
Date:   Tue Jan 3 16:52:56 2017 +1100

    Allow relays to use directory mirrors without a DirPort
    
    These relays need to be contacted over their ORPorts using a begindir
    connection, and relays try not to use begindir connections.
    
    Fixes bug 20711; bugfix on 0.2.8.2-alpha.
---
 changes/bug20711   |  5 +++++
 src/or/directory.c | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/changes/bug20711 b/changes/bug20711
new file mode 100644
index 0000000..01a1ad7
--- /dev/null
+++ b/changes/bug20711
@@ -0,0 +1,5 @@
+  o Minor bugfixes (directory mirrors):
+    - Allow relays to use directory mirrors without a DirPort: these relays
+      need to be contacted over their ORPorts using a begindir connection.
+      Fixes bug 20711; bugfix on 0.2.8.2-alpha.
+
diff --git a/src/or/directory.c b/src/or/directory.c
index 024ed67..a39fc3b 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1067,6 +1067,7 @@ directory_must_use_begindir(const or_options_t *options)
 
 /** Evaluate the situation and decide if we should use an encrypted
  * "begindir-style" connection for this directory request.
+ * 0) If there is no DirPort, yes.
  * 1) If or_port is 0, or it's a direct conn and or_port is firewalled
  *    or we're a dir mirror, no.
  * 2) If we prefer to avoid begindir conns, and we're not fetching or
@@ -1077,15 +1078,22 @@ directory_must_use_begindir(const or_options_t *options)
  */
 static int
 directory_command_should_use_begindir(const or_options_t *options,
-                                      const tor_addr_t *addr,
-                                      int or_port, uint8_t router_purpose,
+                                      const tor_addr_t *or_addr, int or_port,
+                                      const tor_addr_t *dir_addr, int dir_port,
+                                      uint8_t router_purpose,
                                       dir_indirection_t indirection,
                                       const char **reason)
 {
   (void) router_purpose;
+  (void) dir_addr;
   tor_assert(reason);
   *reason = NULL;
 
+  /* Reasons why we must use begindir */
+  if (!dir_port) {
+    *reason = "(using begindir - directory with no DirPort)";
+    return 1; /* We don't know a DirPort -- must begindir. */
+  }
   /* Reasons why we can't possibly use begindir */
   if (!or_port) {
     *reason = "directory with unknown ORPort";
@@ -1098,7 +1106,7 @@ directory_command_should_use_begindir(const or_options_t *options,
   }
   if (indirection == DIRIND_ONEHOP) {
     /* We're firewalled and want a direct OR connection */
-    if (!fascist_firewall_allows_address_addr(addr, or_port,
+    if (!fascist_firewall_allows_address_addr(or_addr, or_port,
                                               FIREWALL_OR_CONNECTION, 0, 0)) {
       *reason = "ORPort not reachable";
       return 0;
@@ -1190,6 +1198,7 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port,
    * send our directory request)? */
   const int use_begindir = directory_command_should_use_begindir(options,
                                      &or_addr_port->addr, or_addr_port->port,
+                                     &dir_addr_port->addr, dir_addr_port->port,
                                      router_purpose, indirection,
                                      &begindir_reason);
   /* Will the connection go via a three-hop Tor circuit? Note that this



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits