summaryrefslogtreecommitdiff
path: root/src/or/connection_or.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2011-11-24 18:59:24 +0100
committerNick Mathewson <nickm@torproject.org>2011-11-30 11:55:46 -0500
commitf89c6196797a6a4b485b3a5eb8788e36eacd9819 (patch)
tree7f96e6e7351a19b59c143cd5c74f24ad850fb785 /src/or/connection_or.c
parentf6ce9e4ea51d1d1ae6d3eb9d5b23d28341e6dd6d (diff)
downloadtor-f89c6196797a6a4b485b3a5eb8788e36eacd9819.tar.gz
tor-f89c6196797a6a4b485b3a5eb8788e36eacd9819.zip
Use the preferred address and port when initiating a connection.
This is not as conservative as we could do it, f.ex. by looking at the connection and only do this for connections to bridges. A non-bridge should never have anything else than its primary IPv4 address set though, so I think this is safe.
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r--src/or/connection_or.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 6990952e94..771e889c91 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -648,8 +648,9 @@ connection_or_init_conn_from_address(or_connection_t *conn,
tor_addr_copy(&conn->real_addr, addr);
if (r) {
tor_addr_t node_addr;
- node_get_addr(r, &node_addr);
- /* XXXX proposal 118 will make this more complex. */
+ node_get_pref_addr(r, &node_addr);
+ /* XXXX proposal 186 is making this more complex. For now, a conn
+ is canonical when it uses the _preferred_ address. */
if (tor_addr_eq(&conn->_base.addr, &node_addr))
conn->is_canonical = 1;
if (!started_here) {
@@ -664,7 +665,7 @@ connection_or_init_conn_from_address(or_connection_t *conn,
* log the "right" port too, so we know if it's moria1 or moria2.
*/
tor_addr_copy(&conn->_base.addr, &node_addr);
- conn->_base.port = node_get_orport(r);
+ conn->_base.port = node_get_pref_orport(r);
}
conn->nickname = tor_strdup(node_get_nickname(r));
tor_free(conn->_base.address);