From 259d2f7207ec7b571ad26cfc4a682af2c6f26faa Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 9 Feb 2008 13:13:38 +0000 Subject: backport r13442 and r13444 svn:r13445 --- ChangeLog | 7 ++++++- src/or/directory.c | 2 +- src/or/or.h | 3 ++- src/or/router.c | 10 +++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60e315312b..ede44c1464 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ Changes in versino 0.1.2.20 - 2008-??-?? - o Minor bugfixes + o Major bugfixes: + - Patch from "Andrew S. Lists" to catch when we contact a directory + mirror at IP address X and he says we look like we're coming from + IP address X. Bugfix on 0.1.2.x. + + o Minor bugfixes: - Stop recommending that every server operator send mail to tor-ops. Resolves bug 597. - Fix a few memory leaks that could in theory happen under bizarre error diff --git a/src/or/directory.c b/src/or/directory.c index d447925c7e..06eae5a89f 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -900,7 +900,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn) if (conn->dirconn_direct) { char *guess = http_get_header(headers, X_ADDRESS_HEADER); if (guess) { - router_new_address_suggestion(guess); + router_new_address_suggestion(guess, conn); tor_free(guess); } } diff --git a/src/or/or.h b/src/or/or.h index 400b80a9d5..6fd403c64f 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2821,7 +2821,8 @@ void mark_my_descriptor_dirty_if_older_than(time_t when); void mark_my_descriptor_dirty(void); void check_descriptor_bandwidth_changed(time_t now); void check_descriptor_ipaddress_changed(time_t now); -void router_new_address_suggestion(const char *suggestion); +void router_new_address_suggestion(const char *suggestion, + const dir_connection_t *conn); int router_compare_to_my_exit_policy(edge_connection_t *conn); routerinfo_t *router_get_my_routerinfo(void); const char *router_get_my_descriptor(void); diff --git a/src/or/router.c b/src/or/router.c index 4173e58189..f4ba1640ad 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1077,7 +1077,8 @@ static uint32_t last_guessed_ip = 0; * If this address is different from the one we think we are now, and * if our computer doesn't actually know its IP address, then switch. */ void -router_new_address_suggestion(const char *suggestion) +router_new_address_suggestion(const char *suggestion, + const dir_connection_t *conn) { uint32_t addr, cur = 0; struct in_addr in; @@ -1107,6 +1108,13 @@ router_new_address_suggestion(const char *suggestion) /* Don't believe anybody who says our IP is, say, 127.0.0.1. */ return; } + if (addr == conn->_base.addr) { + /* Don't believe anybody who says our IP is their IP. */ + log_debug(LD_DIR, "A directory server told us our IP address is %s, " + "but he's just reporting his own IP address. Ignoring.", + suggestion); + return; + } /* Okay. We can't resolve our own address, and X-Your-Address-Is is giving * us an answer different from what we had the last time we managed to -- cgit v1.2.3-54-g00ecf