aboutsummaryrefslogtreecommitdiff
path: root/src/app/config/resolve_addr.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/app/config/resolve_addr.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/app/config/resolve_addr.c')
-rw-r--r--src/app/config/resolve_addr.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/app/config/resolve_addr.c b/src/app/config/resolve_addr.c
index 7ec5ae565a..7368b019d6 100644
--- a/src/app/config/resolve_addr.c
+++ b/src/app/config/resolve_addr.c
@@ -194,7 +194,7 @@ get_address_from_config(const or_options_t *options, int warn_severity,
char **hostname_out, tor_addr_t *addr_out)
{
int ret;
- bool explicit_ip = false;
+ bool explicit_ip = false, resolve_failure = false;
int num_valid_addr = 0;
tor_assert(options);
@@ -246,6 +246,7 @@ get_address_from_config(const or_options_t *options, int warn_severity,
continue;
} else {
/* Hostname that can't be resolved, this is a fatal error. */
+ resolve_failure = true;
log_fn(warn_severity, LD_CONFIG,
"Could not resolve local Address '%s'. Failing.", cfg->value);
continue;
@@ -253,13 +254,16 @@ get_address_from_config(const or_options_t *options, int warn_severity,
}
if (!num_valid_addr) {
- log_fn(warn_severity, LD_CONFIG,
- "No Address option found for family %s in configuration.",
- fmt_af_family(family));
- /* No Address statement for family but one exists since Address is not
- * NULL thus we have to stop now and not attempt to send back a guessed
- * address. */
- return FN_RET_BAIL;
+ if (resolve_failure) {
+ /* We found no address but we got a resolution failure. This means we
+ * can know if the hostname given was v4 or v6 so we can't continue. */
+ return FN_RET_BAIL;
+ }
+ log_info(LD_CONFIG,
+ "No Address option found for family %s in configuration.",
+ fmt_af_family(family));
+ /* No Address statement for family so move on to try next method. */
+ return FN_RET_NEXT;
}
if (num_valid_addr >= MAX_CONFIG_ADDRESS) {