diff options
author | Roger Dingledine <arma@torproject.org> | 2013-02-10 16:45:48 -0500 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2013-02-11 13:29:56 -0500 |
commit | 92ea0b86de30dafe392a2dcd2eb12d9ab83114a7 (patch) | |
tree | 1cfb1df27350e7750914b3557ce1c811de4bb440 /src/or/router.c | |
parent | dfbb12cabf958f0ff2a1004761c22fc093c73dd0 (diff) | |
download | tor-92ea0b86de30dafe392a2dcd2eb12d9ab83114a7.tar.gz tor-92ea0b86de30dafe392a2dcd2eb12d9ab83114a7.zip |
Refactor resolve_my_address() so logs are more accurate / helpful
It returns the method by which we decided our public IP address
(explicitly configured, resolved from explicit hostname, guessed from
interfaces, learned by gethostname).
Now we can provide more helpful log messages when a relay guesses its IP
address incorrectly (e.g. due to unexpected lines in /etc/hosts). Resolves
ticket 2267.
While we're at it, stop sending a stray "(null)" in some cases for the
server status "EXTERNAL_ADDRESS" controller event. Resolves bug 8200.
Diffstat (limited to 'src/or/router.c')
-rw-r--r-- | src/or/router.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/or/router.c b/src/or/router.c index 6c05af9173..735b579fcb 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1712,7 +1712,7 @@ static int router_guess_address_from_dir_headers(uint32_t *guess); int router_pick_published_address(const or_options_t *options, uint32_t *addr) { - if (resolve_my_address(LOG_INFO, options, addr, NULL) < 0) { + if (resolve_my_address(LOG_INFO, options, addr, NULL, NULL) < 0) { log_info(LD_CONFIG, "Could not determine our address locally. " "Checking if directory headers provide any hints."); if (router_guess_address_from_dir_headers(addr) < 0) { @@ -2089,6 +2089,7 @@ check_descriptor_ipaddress_changed(time_t now) { uint32_t prev, cur; const or_options_t *options = get_options(); + const char *method = NULL; char *hostname = NULL; (void) now; @@ -2098,7 +2099,7 @@ check_descriptor_ipaddress_changed(time_t now) /* XXXX ipv6 */ prev = desc_routerinfo->addr; - if (resolve_my_address(LOG_INFO, options, &cur, &hostname) < 0) { + if (resolve_my_address(LOG_INFO, options, &cur, &method, &hostname) < 0) { log_info(LD_CONFIG,"options->Address didn't resolve into an IP."); return; } @@ -2110,7 +2111,10 @@ check_descriptor_ipaddress_changed(time_t now) tor_addr_from_ipv4h(&tmp_prev, prev); tor_addr_from_ipv4h(&tmp_cur, cur); - tor_asprintf(&source, "resolved from %s", hostname); + tor_asprintf(&source, "METHOD=%s %s%s", method, + hostname ? "HOSTNAME=" : "", + hostname ? hostname : ""); + log_addr_has_changed(LOG_NOTICE, &tmp_prev, &tmp_cur, source); tor_free(source); @@ -2151,7 +2155,7 @@ router_new_address_suggestion(const char *suggestion, } /* XXXX ipv6 */ - if (resolve_my_address(LOG_INFO, options, &cur, NULL) >= 0) { + if (resolve_my_address(LOG_INFO, options, &cur, NULL, NULL) >= 0) { /* We're all set -- we already know our address. Great. */ tor_addr_from_ipv4h(&last_guessed_ip, cur); /* store it in case we need it later */ |