diff options
author | Nick Mathewson <nickm@torproject.org> | 2021-01-27 09:36:39 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2021-01-27 09:36:39 -0500 |
commit | b019c8385348e94b2f5d898191af41abc978078b (patch) | |
tree | 0e2ec40600823d35b325b9806aa7fac5cc02f6ce /src/feature/relay | |
parent | 05a762426681ce5e37c7f222c2337a4a1915286c (diff) | |
parent | 3c0d3988473b51b776207fdc8d1b0d332fed2284 (diff) | |
download | tor-b019c8385348e94b2f5d898191af41abc978078b.tar.gz tor-b019c8385348e94b2f5d898191af41abc978078b.zip |
Merge branch 'maint-0.4.5'
Diffstat (limited to 'src/feature/relay')
-rw-r--r-- | src/feature/relay/relay_find_addr.c | 24 | ||||
-rw-r--r-- | src/feature/relay/router.c | 39 |
2 files changed, 36 insertions, 27 deletions
diff --git a/src/feature/relay/relay_find_addr.c b/src/feature/relay/relay_find_addr.c index 2da2328b14..39e1cc6a19 100644 --- a/src/feature/relay/relay_find_addr.c +++ b/src/feature/relay/relay_find_addr.c @@ -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); @@ -131,6 +144,17 @@ relay_find_addr_to_publish, (const or_options_t *options, int family, if (find_my_address(options, family, LOG_INFO, addr_out, NULL, NULL)) { goto 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), + fmt_af_family(family)); } /* Third, consider address from our suggestion cache. */ diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index 781388294b..4fc970683b 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -2070,12 +2070,11 @@ MOCK_IMPL(STATIC int, router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out)) { routerinfo_t *ri = NULL; - tor_addr_t ipv4_addr, ipv6_addr; + tor_addr_t ipv4_addr; char platform[256]; int hibernating = we_are_hibernating(); const or_options_t *options = get_options(); int result = TOR_ROUTERINFO_ERROR_INTERNAL_BUG; - uint16_t ipv6_orport = 0; if (BUG(!ri_out)) { result = TOR_ROUTERINFO_ERROR_INTERNAL_BUG; @@ -2087,10 +2086,6 @@ router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out)) bool have_v4 = relay_find_addr_to_publish(options, AF_INET, RELAY_FIND_ADDR_NO_FLAG, &ipv4_addr); - bool have_v6 = relay_find_addr_to_publish(options, AF_INET6, - RELAY_FIND_ADDR_NO_FLAG, - &ipv6_addr); - /* Tor requires a relay to have an IPv4 so bail if we can't find it. */ if (!have_v4) { log_info(LD_CONFIG, "Don't know my address while generating descriptor. " @@ -2102,24 +2097,21 @@ router_build_fresh_unsigned_routerinfo,(routerinfo_t **ri_out)) /* Log a message if the address in the descriptor doesn't match the ORPort * and DirPort addresses configured by the operator. */ router_check_descriptor_address_consistency(&ipv4_addr); - router_check_descriptor_address_consistency(&ipv6_addr); ri = tor_malloc_zero(sizeof(routerinfo_t)); + tor_addr_copy(&ri->ipv4_addr, &ipv4_addr); ri->cache_info.routerlist_index = -1; ri->nickname = tor_strdup(options->Nickname); /* IPv4. */ - tor_addr_copy(&ri->ipv4_addr, &ipv4_addr); ri->ipv4_orport = routerconf_find_or_port(options, AF_INET); ri->ipv4_dirport = routerconf_find_dir_port(options, 0); - /* IPv6. Do not publish an IPv6 if we don't have an ORPort that can be used - * with the address. This is possible for instance if the ORPort is - * IPv4Only. */ - ipv6_orport = routerconf_find_or_port(options, AF_INET6); - if (have_v6 && ipv6_orport != 0) { - tor_addr_copy(&ri->ipv6_addr, &ipv6_addr); - ri->ipv6_orport = ipv6_orport; + /* Optionally check for an IPv6. We still publish without one. */ + if (relay_find_addr_to_publish(options, AF_INET6, RELAY_FIND_ADDR_NO_FLAG, + &ri->ipv6_addr)) { + ri->ipv6_orport = routerconf_find_or_port(options, AF_INET6); + router_check_descriptor_address_consistency(&ri->ipv6_addr); } ri->supports_tunnelled_dir_requests = @@ -2702,18 +2694,11 @@ check_descriptor_ipaddress_changed(time_t now) previous = &my_ri->ipv6_addr; } - /* Ignore returned value because we want to notice not only an address - * change but also if an address is lost (current == UNSPEC). */ - bool found = find_my_address(get_options(), family, LOG_INFO, ¤t, - &method, &hostname); - if (!found) { - /* Address was possibly not found because it is simply not configured or - * discoverable. Fallback to our cache, which includes any suggestion - * sent by a trusted directory server. */ - found = relay_find_addr_to_publish(get_options(), family, - RELAY_FIND_ADDR_CACHE_ONLY, - ¤t); - } + /* Attempt to discovery the publishable address for the family which will + * actively attempt to discover the address if we are configured with a + * port for the family. */ + relay_find_addr_to_publish(get_options(), family, RELAY_FIND_ADDR_NO_FLAG, + ¤t); /* The "current" address might be UNSPEC meaning it was not discovered nor * found in our current cache. If we had an address before and we have |