Macros | Functions
relay_find_addr.c File Reference

Implement mechanism for a relay to find its address. More...

#include "core/or/or.h"
#include "app/config/config.h"
#include "app/config/resolve_addr.h"
#include "core/mainloop/mainloop.h"
#include "core/or/circuitlist.h"
#include "core/or/circuituse.h"
#include "core/or/extendinfo.h"
#include "feature/control/control_events.h"
#include "feature/dircommon/dir_connection_st.h"
#include "feature/nodelist/dirlist.h"
#include "feature/nodelist/node_select.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerstatus_st.h"
#include "feature/relay/relay_find_addr.h"
#include "feature/relay/router.h"
#include "feature/relay/routermode.h"

Go to the source code of this file.




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)
void relay_addr_learn_from_dirauth (void)

Detailed Description

Implement mechanism for a relay to find its address.

Definition in file relay_find_addr.c.

Macro Definition Documentation



How often should we launch a circuit to an authority to be sure of getting a guess for our IP?

Definition at line 163 of file relay_find_addr.c.

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 49 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 107 of file relay_find_addr.c.

Referenced by 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 154 of file relay_find_addr.c.

Referenced by dirclient_fetches_from_authorities().