Enumerations | Functions
relay_find_addr.h File Reference

Header file for relay_find_addr.c. More...

Go to the source code of this file.


enum  relay_find_addr_flags_t { RELAY_FIND_ADDR_NO_FLAG = (1U << 0), RELAY_FIND_ADDR_CACHE_ONLY = (1U << 1) }


void relay_address_new_suggestion (const tor_addr_t *suggested_addr, const tor_addr_t *peer_addr, const char *identity_digest)
bool relay_find_addr_to_publish (const or_options_t *options, int family, int flags, tor_addr_t *addr_out)
bool relay_has_address_set (int family)

Detailed Description

Header file for relay_find_addr.c.

Definition in file relay_find_addr.h.

Function Documentation

◆ relay_address_new_suggestion()

void relay_address_new_suggestion ( const tor_addr_t suggested_addr,
const tor_addr_t peer_addr,
const char *  identity_digest 

Consider the address suggestion suggested_addr as a possible one to use as our address.

This is called when a valid NETINFO cell is received containing a candidate for our address or when a directory sends us back the X-Your-Address-Is header.

The suggested address is ignored if it does NOT come from a trusted source. At the moment, we only look a trusted directory authorities.

The suggested address is ignored if it is internal or it is the same as the given peer_addr which is the address from the endpoint that sent the NETINFO cell.

The identity_digest is NULL if this is an address suggested by a directory since this is a plaintext connection.

The suggested address is set in our suggested address cache if everything passes.

Definition at line 43 of file relay_find_addr.c.

◆ relay_find_addr_to_publish()

bool relay_find_addr_to_publish ( const or_options_t options,
int  family,
int  flags,
tor_addr_t addr_out 

Find our address to be published in our descriptor. Three places are looked at:

  1. Resolved cache. Populated by find_my_address() during the relay periodic event that attempts to learn if our address has changed.
  2. If flags is set with RELAY_FIND_ADDR_CACHE_ONLY, only the resolved and suggested cache are looked at. No address discovery will be done.
  3. Finally, if all fails, use the suggested address cache which is populated by the NETINFO cell content or HTTP header from a directory.

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.

Definition at line 101 of file relay_find_addr.c.

Referenced by launch_dummy_descriptor_download_as_needed(), pt_get_extra_info_descriptor_string(), and relay_has_address_set().

◆ relay_has_address_set()

bool relay_has_address_set ( int  family)

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.

Definition at line 148 of file relay_find_addr.c.

Referenced by dirclient_fetches_from_authorities().