diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-02-27 11:00:02 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-02-27 11:00:02 -0500 |
commit | 2b3518b81fbec1eda8b8924a21c464f63bd1984d (patch) | |
tree | c2231318af3a1a6227c7a5db34b923749fd36b35 /src | |
parent | b6efd77ec4f891ddaaeafa1c74c45454dde2fdd8 (diff) | |
parent | 518ef61975b569eb604b30c92d965e98373c2673 (diff) | |
download | tor-2b3518b81fbec1eda8b8924a21c464f63bd1984d.tar.gz tor-2b3518b81fbec1eda8b8924a21c464f63bd1984d.zip |
Merge remote-tracking branch 'teor/bug20711' into maint-0.3.0
Diffstat (limited to 'src')
-rw-r--r-- | src/or/directory.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 80d3c30c63..70437fe755 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -1066,6 +1066,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 @@ -1076,15 +1077,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"; @@ -1097,7 +1105,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; @@ -1189,6 +1197,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 @@ -1235,9 +1244,9 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port, if (!port || tor_addr_is_null(&addr)) { static int logged_backtrace = 0; log_warn(LD_DIR, - "Cannot make an outgoing %sconnection without %sPort.", + "Cannot make an outgoing %sconnection without a remote %sPort.", use_begindir ? "begindir " : "", - use_begindir ? "an OR" : "a Dir"); + use_begindir ? "OR" : "Dir"); if (!logged_backtrace) { log_backtrace(LOG_INFO, LD_BUG, "Address came from"); logged_backtrace = 1; |