aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/or/connection_edge.c14
-rw-r--r--src/or/directory.c3
2 files changed, 11 insertions, 6 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index d9f4787c5d..0474a469d7 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -2458,8 +2458,12 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
end_payload, 1, NULL);
return 0;
}
- if (or_circ && or_circ->p_conn && or_circ->p_conn->_base.address)
- address = tor_strdup(or_circ->p_conn->_base.address);
+ /* Make sure to get the 'real' address of the previous hop: the
+ * caller might want to know whether his IP address has changed, and
+ * we might already have corrected _base.addr[ess] for the relay's
+ * canonical IP address. */
+ if (or_circ && or_circ->p_conn)
+ address = tor_dup_addr(or_circ->p_conn->real_addr);
else
address = tor_strdup("127.0.0.1");
port = 1; /* XXXX This value is never actually used anywhere, and there
@@ -2533,8 +2537,8 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
if (rh.command == RELAY_COMMAND_BEGIN_DIR) {
tor_assert(or_circ);
- if (or_circ->p_conn && or_circ->p_conn->_base.addr)
- n_stream->_base.addr = or_circ->p_conn->_base.addr;
+ if (or_circ->p_conn && &or_circ->p_conn->real_addr)
+ n_stream->_base.addr = or_circ->p_conn->real_addr;
return connection_exit_connect_dir(n_stream);
}
@@ -2718,7 +2722,7 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
dirconn->_base.addr = exitconn->_base.addr;
dirconn->_base.port = 0;
- dirconn->_base.address = tor_strdup(circ->p_conn->_base.address);
+ dirconn->_base.address = tor_strdup(exitconn->_base.address);
dirconn->_base.type = CONN_TYPE_DIR;
dirconn->_base.purpose = DIR_PURPOSE_SERVER;
dirconn->_base.state = DIR_CONN_STATE_SERVER_COMMAND_WAIT;
diff --git a/src/or/directory.c b/src/or/directory.c
index 46721e7fc8..9362c210c8 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -635,7 +635,8 @@ directory_command_should_use_begindir(or_options_t *options, uint32_t addr,
return 0; /* We don't know an ORPort -- no chance. */
if (!anonymized_connection)
if (!fascist_firewall_allows_address_or(addr, or_port) ||
- directory_fetches_from_authorities(options))
+ directory_fetches_from_authorities(options) ||
+ (server_mode(options) && !options->Address))
return 0; /* We're firewalled or are acting like a relay -- also no. */
if (!options->TunnelDirConns &&
router_purpose != ROUTER_PURPOSE_BRIDGE)