diff options
Diffstat (limited to 'src/feature/relay/relay_find_addr.c')
-rw-r--r-- | src/feature/relay/relay_find_addr.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/src/feature/relay/relay_find_addr.c b/src/feature/relay/relay_find_addr.c index 9c2c8b281c..33a50ce3c3 100644 --- a/src/feature/relay/relay_find_addr.c +++ b/src/feature/relay/relay_find_addr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2001-2020, The Tor Project, Inc. */ +/* Copyright (c) 2001-2021, The Tor Project, Inc. */ /* See LICENSE for licensing information */ /** @@ -99,6 +99,13 @@ relay_address_new_suggestion(const tor_addr_t *suggested_addr, * populated by the NETINFO cell content or HTTP header from a * directory. * + * The AddressDisableIPv6 is checked here for IPv6 address discovery and if + * set, false is returned and addr_out is UNSPEC. + * + * Before doing any discovery, the configuration is checked for an ORPort of + * the given family. If none can be found, false is returned and addr_out is + * UNSPEC. + * * Return true on success and addr_out contains the address to use for the * given family. On failure to find the address, false is returned and * addr_out is set to an AF_UNSPEC address. */ @@ -118,6 +125,12 @@ relay_find_addr_to_publish, (const or_options_t *options, int family, return false; } + /* There is no point on attempting an address discovery to publish if we + * don't have an ORPort for this family. */ + if (!routerconf_find_or_port(options, family)) { + return false; + } + /* First, check our resolved address cache. It should contain the address * we've discovered from the periodic relay event. */ resolved_addr_get_last(family, addr_out); @@ -139,25 +152,26 @@ relay_find_addr_to_publish, (const or_options_t *options, int family, goto found; } - /* No publishable address was found. */ + /* No publishable address was found even though we have an ORPort thus + * print a notice log so operator can notice. We'll do that every hour so + * it is not too spammy but enough so operators address the issue. */ + static ratelim_t rlim = RATELIM_INIT(3600); + log_fn_ratelim(&rlim, LOG_NOTICE, LD_CONFIG, + "Unable to find %s address for ORPort %u. " + "You might want to specify %sOnly to it or set an " + "explicit address or set Address.", + fmt_af_family(family), + routerconf_find_or_port(options, family), + (family == AF_INET) ? fmt_af_family(AF_INET6) : + fmt_af_family(AF_INET)); + + /* Not found. */ return false; found: return true; } -/** Return true iff this relay has an address set for the given family. - * - * This only checks the caches so it will not trigger a full discovery of the - * address. */ -bool -relay_has_address_set(int family) -{ - tor_addr_t addr; - return relay_find_addr_to_publish(get_options(), family, - RELAY_FIND_ADDR_CACHE_ONLY, &addr); -} - /** How often should we launch a circuit to an authority to be sure of getting * a guess for our IP? */ #define DUMMY_DOWNLOAD_INTERVAL (20*60) @@ -198,9 +212,13 @@ relay_addr_learn_from_dirauth(void) return; } const node_t *node = node_get_by_id(rs->identity_digest); - if (BUG(!node)) { - /* If there is a routerstatus_t, there is a node_t thus this should - * never fail. */ + if (!node) { + /* This can happen if we are still in the early starting stage where no + * descriptors we actually fetched and thus we have the routerstatus_t + * for the authority but not its descriptor which is needed to build a + * circuit and thus learn our address. */ + log_info(LD_GENERAL, "Can't build a circuit to an authority. Unable to " + "learn for now our address from them."); return; } extend_info_t *ei = extend_info_from_node(node, 1); |