From: Roger Dingledine Date: Tue, 13 Jun 2006 05:36:35 +0000 (+0000) Subject: Fix the bug that was causing servers to not find themselves X-Git-Tag: tor-0.1.1.23~232 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab61c40661faa59a83d644101e36fbc102b87f18;p=thirdparty%2Ftor.git Fix the bug that was causing servers to not find themselves reachable if they changed IP addresses. This happened because middle servers knew the old descriptor, and kept swapping the addr/port we asked for with the one they thought was right. So the create cell never got sent, because it was asking for a different addr/port than we believed we had connected to. svn:r6610 --- diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 85cfa83ee7..642bddfb2a 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -306,22 +306,6 @@ connection_or_finished_connecting(connection_t *conn) return 0; } -/** Initialize conn to include all the relevant data from router. - * This function is called either from connection_or_connect(), if - * we initiated the connect, or from connection_tls_finish_handshake() - * if the other side initiated it. - */ -static void -connection_or_init_conn_from_router(connection_t *conn, routerinfo_t *router) -{ - conn->addr = router->addr; - conn->port = router->or_port; - connection_or_set_identity_digest(conn, router->cache_info.identity_digest); - conn->nickname = tor_strdup(router->nickname); - tor_free(conn->address); - conn->address = tor_strdup(router->address); -} - /** If we don't necessarily know the router we're connecting to, but we * have an addr/port/id_digest, then fill in as much as we can. Start * by checking to see if this describes a router we know. */ @@ -335,13 +319,22 @@ connection_or_init_conn_from_address(connection_t *conn, routerinfo_t *r = router_get_by_digest(id_digest); conn->bandwidthrate = (int)options->BandwidthRate; conn->receiver_bucket = conn->bandwidthburst = (int)options->BandwidthBurst; + connection_or_set_identity_digest(conn, id_digest); + conn->addr = addr; + conn->port = port; if (r) { - connection_or_init_conn_from_router(conn,r); + if (!started_here) { + /* Override the addr/port, so our log messages will make sense. + * This is dangerous, since if we ever try looking up a conn by + * its actual addr/port, we won't remember. Careful! */ + conn->addr = r->addr; + conn->port = r->or_port; + } + conn->nickname = tor_strdup(r->nickname); + tor_free(conn->address); + conn->address = tor_strdup(r->address); } else { const char *n; - conn->addr = addr; - conn->port = port; - connection_or_set_identity_digest(conn, id_digest); /* If we're an authoritative directory server, we may know a * nickname for this router. */ n = dirserv_get_nickname_by_digest(id_digest);