Functions | Variables
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 "feature/control/control_events.h"
#include "feature/dircommon/dir_connection_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.


static int router_guess_address_from_dir_headers (uint32_t *guess)
void router_new_address_suggestion (const char *suggestion, const dir_connection_t *d_conn)
int router_pick_published_address (const or_options_t *options, uint32_t *addr, int cache_only)


static tor_addr_t last_guessed_ip = TOR_ADDR_NULL

Detailed Description

Implement mechanism for a relay to find its address.

Definition in file relay_find_addr.c.

Function Documentation

◆ router_guess_address_from_dir_headers()

static int router_guess_address_from_dir_headers ( uint32_t *  guess)

We failed to resolve our address locally, but we'd like to build a descriptor and publish / test reachability. If we have a guess about our address based on directory headers, answer it and return 0; else return -1.

Definition at line 31 of file relay_find_addr.c.

◆ router_new_address_suggestion()

void router_new_address_suggestion ( const char *  suggestion,
const dir_connection_t d_conn 

A directory server d_conn told us our IP address is suggestion. If this address is different from the one we think we are now, and if our computer doesn't actually know its IP address, then switch.

Definition at line 45 of file relay_find_addr.c.

◆ router_pick_published_address()

int router_pick_published_address ( const or_options_t options,
uint32_t *  addr,
int  cache_only 

Make a current best guess at our address, either because it's configured in torrc, or because we've learned it from dirserver headers. Place the answer in *addr and return 0 on success, else return -1 if we have no guess.

If cache_only is true, just return any cached answers, and don't try to get any new answers.

Definition at line 119 of file relay_find_addr.c.

Referenced by dirclient_fetches_from_authorities(), pt_get_extra_info_descriptor_string(), and router_rebuild_descriptor().

Variable Documentation

◆ last_guessed_ip

tor_addr_t last_guessed_ip = TOR_ADDR_NULL

The most recently guessed value of our IP address, based on directory headers.

Definition at line 24 of file relay_find_addr.c.

Referenced by router_guess_address_from_dir_headers().