Clear the cached address from resolve_my_address() when our IP changes

Closes 11582; patch from "ra".
This commit is contained in:
Nick Mathewson 2014-09-29 13:46:30 -04:00
parent e440993f95
commit b448ec195d
4 changed files with 15 additions and 0 deletions

5
changes/ticket11582 Normal file
View File

@ -0,0 +1,5 @@
o Minor features:
- Re-check our address after we detect a changed IP address from
getsockname(). This ensures that the controller command "GETINFO
address" will report the correct value. Resolves ticket 11582.
Patch from "ra".

View File

@ -2037,6 +2037,13 @@ get_last_resolved_addr(void)
return last_resolved_addr;
}
/** Reset last_resolved_addr from outside this file. */
void
reset_last_resolved_addr(void)
{
last_resolved_addr = 0;
}
/**
* Use <b>options-\>Address</b> to guess our public IP address.
*

View File

@ -29,6 +29,7 @@ setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
int clear_first, char **msg);
uint32_t get_last_resolved_addr(void);
void reset_last_resolved_addr(void);
int resolve_my_address(int warn_severity, const or_options_t *options,
uint32_t *addr_out,
const char **method_out, char **hostname_out);

View File

@ -4386,6 +4386,8 @@ client_check_address_changed(tor_socket_t sock)
SMARTLIST_FOREACH(outgoing_addrs, tor_addr_t*, a_ptr, tor_free(a_ptr));
smartlist_clear(outgoing_addrs);
smartlist_add(outgoing_addrs, tor_memdup(&out_addr, sizeof(tor_addr_t)));
/* We'll need to resolve ourselves again. */
reset_last_resolved_addr();
/* Okay, now change our keys. */
ip_address_changed(1);
}