diff options
author | David Goulet <dgoulet@torproject.org> | 2020-07-14 12:58:36 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-07-20 14:54:13 -0400 |
commit | 1a347b4790719d6ae1576c0b023dac343b65e5a1 (patch) | |
tree | 3e7f6ef4018caa7947a4d31d439801b0be94aa53 /src/feature/dirclient | |
parent | 35871e46e89ae0182703b2e20fe9e9c1e0f20cef (diff) | |
download | tor-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/dirclient')
-rw-r--r-- | src/feature/dirclient/dirclient_modes.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/feature/dirclient/dirclient_modes.c b/src/feature/dirclient/dirclient_modes.c index 31a3f8af58..62cdad6c36 100644 --- a/src/feature/dirclient/dirclient_modes.c +++ b/src/feature/dirclient/dirclient_modes.c @@ -40,15 +40,19 @@ int dirclient_fetches_from_authorities(const or_options_t *options) { const routerinfo_t *me; - uint32_t addr; int refuseunknown; if (options->FetchDirInfoEarly) return 1; if (options->BridgeRelay == 1) return 0; - if (server_mode(options) && - router_pick_published_address(options, &addr, 1) < 0) - return 1; /* we don't know our IP address; ask an authority. */ + /* We don't know our IP address; ask an authority. IPv4 is still mandatory + * to have thus if we don't have it, we ought to learn it from an authority + * through the NETINFO cell or the HTTP header it sends us back. + * + * Note that at the moment, relay do a direct connection so no NETINFO cell + * for now. */ + if (server_mode(options) && !relay_has_address_set(AF_INET)) + return 1; refuseunknown = ! router_my_exit_policy_is_reject_star() && should_refuse_unknown_exits(options); if (!dir_server_mode(options) && !refuseunknown) |