mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 13:43:47 +01:00
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>
This commit is contained in:
parent
35871e46e8
commit
1a347b4790
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user