aboutsummaryrefslogtreecommitdiff
path: root/src/feature/relay
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-07-14 12:58:36 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-07-20 14:54:13 -0400
commit1a347b4790719d6ae1576c0b023dac343b65e5a1 (patch)
tree3e7f6ef4018caa7947a4d31d439801b0be94aa53 /src/feature/relay
parent35871e46e89ae0182703b2e20fe9e9c1e0f20cef (diff)
downloadtor-1a347b4790719d6ae1576c0b023dac343b65e5a1.tar.gz
tor-1a347b4790719d6ae1576c0b023dac343b65e5a1.zip
relay: Deciding to fetch from authority, use new find address API
Use the new relay_has_address_set() interface when deciding if we need to fetch directory information from an authority as a relay. If no IPv4 address is found, we'll proceed with a fetch so we can learn our address in the HTTP header or NETINFO cell that a trusted authority will send us back. Related to #40025 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/relay')
-rw-r--r--src/feature/relay/relay_find_addr.c11
-rw-r--r--src/feature/relay/relay_find_addr.h2
2 files changed, 13 insertions, 0 deletions
diff --git a/src/feature/relay/relay_find_addr.c b/src/feature/relay/relay_find_addr.c
index dabf985751..d685145934 100644
--- a/src/feature/relay/relay_find_addr.c
+++ b/src/feature/relay/relay_find_addr.c
@@ -254,3 +254,14 @@ router_pick_published_address, (const or_options_t *options, uint32_t *addr,
/* We have no useful cached answers. Return failure. */
return -1;
}
+
+/** 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, 1, &addr);
+}
diff --git a/src/feature/relay/relay_find_addr.h b/src/feature/relay/relay_find_addr.h
index e28ceb933a..399ac8dc44 100644
--- a/src/feature/relay/relay_find_addr.h
+++ b/src/feature/relay/relay_find_addr.h
@@ -22,6 +22,8 @@ void relay_address_new_suggestion(const tor_addr_t *suggested_addr,
bool relay_find_addr_to_publish(const or_options_t *options, int family,
bool cache_only, tor_addr_t *addr_out);
+bool relay_has_address_set(int family);
+
#ifdef RELAY_FIND_ADDR_PRIVATE
#endif /* RELAY_FIND_ADDR_PRIVATE */