aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_config.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-07-20 14:20:53 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-07-20 14:51:42 -0400
commitc18e52af7ce178e0dc78830e41948a9298e6d314 (patch)
treec6102a6edbb9f15065e76df5d1a7e34f0ca44814 /src/test/test_config.c
parentb18e2749191dd261462d12a315cd79fcbbccbefa (diff)
downloadtor-c18e52af7ce178e0dc78830e41948a9298e6d314.tar.gz
tor-c18e52af7ce178e0dc78830e41948a9298e6d314.zip
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 <dgoulet@torproject.org>
Diffstat (limited to 'src/test/test_config.c')
-rw-r--r--src/test/test_config.c47
1 files changed, 0 insertions, 47 deletions
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);
@@ -1543,49 +1539,6 @@ test_config_find_my_address(void *arg)
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
* 2. Interface address is a valid address.