Fixes for bug4645 fix.

This commit is contained in:
Nick Mathewson 2014-02-03 14:31:31 -05:00
parent e82e772f2b
commit dafed84dab
2 changed files with 9 additions and 12 deletions

View File

@ -2108,22 +2108,22 @@ resolve_my_address(int warn_severity, const or_options_t *options,
if (!explicit_hostname &&
tor_addr_is_internal(&myaddr, 0)) {
uint32_t interface_ip;
tor_addr_t interface_ip;
log_fn(notice_severity, LD_CONFIG, "Guessed local hostname '%s' "
"resolves to a private IP address (%s). Trying something "
"else.", hostname, fmt_addr32(addr));
if (get_interface_address(warn_severity, &interface_ip)) {
if (get_interface_address6(warn_severity, AF_INET, &interface_ip)<0) {
log_fn(warn_severity, LD_CONFIG,
"Could not get local interface IP address. Too bad.");
} else if (tor_addr_is_internal(&myaddr, 0)) {
} else if (tor_addr_is_internal(&interface_ip, 0)) {
log_fn(notice_severity, LD_CONFIG,
"Interface IP address '%s' is a private address too. "
"Ignoring.", fmt_addr32(interface_ip));
"Ignoring.", fmt_addr(&interface_ip));
} else {
from_interface = 1;
addr = interface_ip;
addr = tor_addr_to_ipv4h(&interface_ip);
log_fn(notice_severity, LD_CONFIG,
"Learned IP address '%s' for local interface."
" Using that.", fmt_addr32(addr));

View File

@ -524,20 +524,17 @@ dirserv_free_fingerprint_list(void)
static int
dirserv_router_has_valid_address(routerinfo_t *ri)
{
struct in_addr iaddr;
tor_addr_t addr;
if (get_options()->DirAllowPrivateAddresses)
return 0; /* whatever it is, we're fine with it */
if (!tor_inet_aton(ri->address, &iaddr)) {
log_info(LD_DIRSERV,"Router %s published non-IP address '%s'. Refusing.",
if (tor_addr_parse(&addr, ri->address) != AF_INET) {
log_info(LD_DIRSERV,"Router %s published non-IPv4 address '%s'. Refusing.",
router_describe(ri),
ri->address);
return -1;
}
tor_addr_t toraddr;
tor_addr_from_in(&toraddr,&iaddr);
if (tor_addr_is_internal(&toraddr, 0)) {
if (tor_addr_is_internal(&addr, 0)) {
log_info(LD_DIRSERV,
"Router %s published internal IP address '%s'. Refusing.",
router_describe(ri), ri->address);