From c18e52af7ce178e0dc78830e41948a9298e6d314 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 20 Jul 2020 14:20:53 -0400 Subject: addr: Continue discovery if Address exits but not for wanted family Commit b14b1f2b1d9 was a mistake. In case an Address statement is missing for the wanted family but another one exists for another family, simply continue the address discovery. It is not a mistake to be missing an Address statement for a family because the address could simply be discovered by the next methods. Not all address family requires a specific Address statement. However, we do bail if we couldn't find any valid address for the requested family _and_ a resolve failed meaning we had a hostname but couldn't resolve it. In that case, we can't know if that hostname would have been for v4 or v6 thus we can't continue the address discovery properly. Couple unit tests case were removed to match this reality. Related #40025 Signed-off-by: David Goulet --- src/test/test_config.c | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) (limited to 'src/test/test_config.c') diff --git a/src/test/test_config.c b/src/test/test_config.c index cdf668be49..a50e6ac927 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -1290,10 +1290,6 @@ test_config_find_my_address_mixed(void *arg) "2a01:4f8:fff0:4f:266:37ff:fe2c:5d19"); tor_addr_parse(&test_addr, "2a01:4f8:fff0:4f:266:37ff:fe2c:5d19"); - /* IPv4 address not guessed since one Address statement exists. */ - retval = find_my_address(options, AF_INET, LOG_NOTICE, &resolved_addr, - &method_used, &hostname_out); - VALIDATE_FOUND_ADDRESS(false, NULL, NULL); /* IPv6 address should be found and considered configured. */ retval = find_my_address(options, AF_INET6, LOG_NOTICE, &resolved_addr, &method_used, &hostname_out); @@ -1542,49 +1538,6 @@ test_config_find_my_address(void *arg) VALIDATE_FOUND_ADDRESS(false, NULL, NULL); CLEANUP_FOUND_ADDRESS; - /* - * Case 6: Another address family is configured. Expected to fail. - */ - if (p->family == AF_INET) { - config_line_append(&options->Address, "Address", "4242::4242"); - } else { - config_line_append(&options->Address, "Address", "1.1.1.1"); - } - - setup_full_capture_of_logs(LOG_NOTICE); - - retval = find_my_address(options, p->family, LOG_NOTICE, &resolved_addr, - &method_used, &hostname_out); - - expect_log_msg_containing("No Address option found for family"); - teardown_capture_of_logs(); - - VALIDATE_FOUND_ADDRESS(false, NULL, NULL); - CLEANUP_FOUND_ADDRESS; - - /* - * Case 7: Address is a non resolvable hostname. Expected to fail. - */ - MOCK(tor_addr_lookup, tor_addr_lookup_failure); - - config_line_append(&options->Address, "Address", "www.torproject.org"); - prev_n_hostname_failure = n_hostname_failure; - - setup_full_capture_of_logs(LOG_NOTICE); - - retval = find_my_address(options, p->family, LOG_NOTICE, &resolved_addr, - &method_used, &hostname_out); - - expect_log_msg_containing("Could not resolve local Address " - "'www.torproject.org'. Failing."); - teardown_capture_of_logs(); - - tt_int_op(n_hostname_failure, OP_EQ, ++prev_n_hostname_failure); - VALIDATE_FOUND_ADDRESS(false, NULL, NULL); - CLEANUP_FOUND_ADDRESS; - - UNMOCK(tor_addr_lookup); - /* * Case 8: * 1. Address is NULL -- cgit v1.2.3-54-g00ecf