diff options
author | Roger Dingledine <arma@torproject.org> | 2008-02-09 10:36:49 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2008-02-09 10:36:49 +0000 |
commit | b42c9d69f0e7a432fcf5b3283850b03954a911ae (patch) | |
tree | ba977d45ee193fa24287c6328a7578ef8ce634cb /src | |
parent | 509d2912dcc533ececaa9f09f96271ae57a7f275 (diff) | |
download | tor-b42c9d69f0e7a432fcf5b3283850b03954a911ae.tar.gz tor-b42c9d69f0e7a432fcf5b3283850b03954a911ae.zip |
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.
svn:r13442
Diffstat (limited to 'src')
-rw-r--r-- | src/or/directory.c | 2 | ||||
-rw-r--r-- | src/or/or.h | 3 | ||||
-rw-r--r-- | src/or/router.c | 10 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 8ca183cfe6..9dd1a81050 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -1257,7 +1257,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 ca6e062a41..44e19c6cf1 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3779,7 +3779,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 *d_conn); int router_compare_to_my_exit_policy(edge_connection_t *conn); routerinfo_t *router_get_my_routerinfo(void); extrainfo_t *router_get_my_extrainfo(void); diff --git a/src/or/router.c b/src/or/router.c index 6388d244e2..c74368ea88 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1464,7 +1464,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 *d_conn) { uint32_t addr, cur = 0; struct in_addr in; @@ -1494,6 +1495,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 == d_conn->_base.addr) { + /* Don't believe anybody who says our IP is their IP. */ + log_notice(LD_DIR, "A directory server told us our IP is %s, but that " + "seems to be the IP of the directory server saying these " + "things. 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 |