tor  0.4.2.1-alpha-dev
Macros | Typedefs | Enumerations | Functions
node_select.h File Reference

Go to the source code of this file.

Macros

#define PDS_ALLOW_SELF   (1<<0)
 
#define PDS_RETRY_IF_NO_SERVERS   (1<<1)
 
#define PDS_IGNORE_FASCISTFIREWALL   (1<<2)
 
#define PDS_NO_EXISTING_SERVERDESC_FETCH   (1<<3)
 
#define PDS_NO_EXISTING_MICRODESC_FETCH   (1<<4)
 

Typedefs

typedef enum router_crn_flags_t router_crn_flags_t
 
typedef enum bandwidth_weight_rule_t bandwidth_weight_rule_t
 

Enumerations

enum  router_crn_flags_t {
  CRN_NEED_UPTIME = 1<<0, CRN_NEED_CAPACITY = 1<<1, CRN_NEED_GUARD = 1<<2, CRN_WEIGHT_AS_EXIT = 1<<5,
  CRN_NEED_DESC = 1<<6, CRN_PREF_ADDR = 1<<7, CRN_DIRECT_CONN = 1<<8, CRN_RENDEZVOUS_V3 = 1<<9
}
 
enum  bandwidth_weight_rule_t {
  NO_WEIGHTING, WEIGHT_FOR_EXIT, WEIGHT_FOR_MID, WEIGHT_FOR_GUARD,
  WEIGHT_FOR_DIR
}
 

Functions

const routerstatus_trouter_pick_directory_server (dirinfo_type_t type, int flags)
 
int router_get_my_share_of_directory_requests (double *v3_share_out)
 
const node_tnode_sl_choose_by_bandwidth (const smartlist_t *sl, bandwidth_weight_rule_t rule)
 
double frac_nodes_with_descriptors (const smartlist_t *sl, bandwidth_weight_rule_t rule, int for_direct_conn)
 
const node_trouter_choose_random_node (smartlist_t *excludedsmartlist, struct routerset_t *excludedset, router_crn_flags_t flags)
 
const routerstatus_trouter_pick_trusteddirserver (dirinfo_type_t type, int flags)
 
const routerstatus_trouter_pick_fallback_dirserver (dirinfo_type_t type, int flags)
 

Detailed Description

Header file for node_select.c.

Definition in file node_select.h.

Macro Definition Documentation

◆ PDS_ALLOW_SELF

#define PDS_ALLOW_SELF   (1<<0)

Flag to indicate that we should not automatically be willing to use ourself to answer a directory request. Passed to router_pick_directory_server (et al).

Definition at line 44 of file node_select.h.

◆ PDS_IGNORE_FASCISTFIREWALL

#define PDS_IGNORE_FASCISTFIREWALL   (1<<2)

Flag to indicate that we should not exclude directory servers that our ReachableAddress settings would exclude. This usually means that we're going to connect to the server over Tor, and so we don't need to worry about our firewall telling us we can't. Passed to router_pick_directory_server (et al).

Definition at line 54 of file node_select.h.

◆ PDS_NO_EXISTING_MICRODESC_FETCH

#define PDS_NO_EXISTING_MICRODESC_FETCH   (1<<4)

Flag to indicate that we should not use any directory authority to which we have an existing directory connection for downloading microdescs.

Passed to router_pick_directory_server (et al)

Definition at line 67 of file node_select.h.

◆ PDS_NO_EXISTING_SERVERDESC_FETCH

#define PDS_NO_EXISTING_SERVERDESC_FETCH   (1<<3)

Flag to indicate that we should not use any directory authority to which we have an existing directory connection for downloading server descriptors or extrainfo documents.

Passed to router_pick_directory_server (et al)

Definition at line 61 of file node_select.h.

◆ PDS_RETRY_IF_NO_SERVERS

#define PDS_RETRY_IF_NO_SERVERS   (1<<1)

Flag to indicate that if no servers seem to be up, we should mark all directory servers as up and try again. Passed to router_pick_directory_server (et al).

Definition at line 48 of file node_select.h.

Typedef Documentation

◆ bandwidth_weight_rule_t

Possible ways to weight routers when choosing one randomly. See routerlist_sl_choose_by_bandwidth() for more information.

◆ router_crn_flags_t

Flags to be passed to control router_choose_random_node() to indicate what kind of nodes to pick according to what algorithm.

Enumeration Type Documentation

◆ bandwidth_weight_rule_t

Possible ways to weight routers when choosing one randomly. See routerlist_sl_choose_by_bandwidth() for more information.

Definition at line 35 of file node_select.h.

◆ router_crn_flags_t

Flags to be passed to control router_choose_random_node() to indicate what kind of nodes to pick according to what algorithm.

Definition at line 16 of file node_select.h.

Function Documentation

◆ frac_nodes_with_descriptors()

double frac_nodes_with_descriptors ( const smartlist_t sl,
bandwidth_weight_rule_t  rule,
int  for_direct_conn 
)

For all nodes in sl, return the fraction of those nodes, weighted by their weighted bandwidths with rule rule, for which we have descriptors.

If for_direct_connect is true, we intend to connect to the node directly, as the first hop of a circuit; otherwise, we intend to connect to it indirectly, or use it as if we were connecting to it indirectly.

Definition at line 768 of file node_select.c.

◆ node_sl_choose_by_bandwidth()

const node_t* node_sl_choose_by_bandwidth ( const smartlist_t sl,
bandwidth_weight_rule_t  rule 
)

Choose a random element of status list sl, weighted by the advertised bandwidth of each node

Definition at line 803 of file node_select.c.

References smartlist_choose_node_by_bandwidth_weights().

◆ router_choose_random_node()

const node_t* router_choose_random_node ( smartlist_t excludedsmartlist,
routerset_t *  excludedset,
router_crn_flags_t  flags 
)

Return a random running node from the nodelist. Never pick a node that is in excludedsmartlist, or which matches excludedset, even if they are the only nodes available. If CRN_NEED_UPTIME is set in flags and any router has more than a minimum uptime, return one of those. If CRN_NEED_CAPACITY is set in flags, weight your choice by the advertised capacity of each router. If CRN_NEED_GUARD is set in flags, consider only Guard routers. If CRN_WEIGHT_AS_EXIT is set in flags, we weight bandwidths as if picking an exit node, otherwise we weight bandwidths for picking a relay node (that is, possibly discounting exit nodes). If CRN_NEED_DESC is set in flags, we only consider nodes that have a routerinfo or microdescriptor – that is, enough info to be used to build a circuit. If CRN_PREF_ADDR is set in flags, we only consider nodes that have an address that is preferred by the ClientPreferIPv6ORPort setting (regardless of this flag, we exclude nodes that aren't allowed by the firewall, including ClientUseIPv4 0 and fascist_firewall_use_ipv6() == 0).

Definition at line 903 of file node_select.c.

◆ router_pick_directory_server()

const routerstatus_t* router_pick_directory_server ( dirinfo_type_t  type,
int  flags 
)

Try to find a running dirserver that supports operations of type.

If there are no running dirservers in our routerlist and the PDS_RETRY_IF_NO_SERVERS flag is set, set all the fallback ones (including authorities) as running again, and pick one.

If the PDS_IGNORE_FASCISTFIREWALL flag is set, then include dirservers that we can't reach.

If the PDS_ALLOW_SELF flag is not set, then don't include ourself (if we're a dirserver).

Don't pick a fallback directory mirror if any non-fallback is viable; (the fallback directory mirrors include the authorities) try to avoid using servers that have returned 503 recently.

Definition at line 71 of file node_select.c.

◆ router_pick_fallback_dirserver()

const routerstatus_t* router_pick_fallback_dirserver ( dirinfo_type_t  type,
int  flags 
)

Try to find a running fallback directory. Flags are as for router_pick_directory_server.

Definition at line 1006 of file node_select.c.

◆ router_pick_trusteddirserver()

const routerstatus_t* router_pick_trusteddirserver ( dirinfo_type_t  type,
int  flags 
)

Try to find a running directory authority. Flags are as for router_pick_directory_server.

Definition at line 995 of file node_select.c.