Tor  0.4.5.0-alpha-dev
Macros | Enumerations | Functions
node_select.h File Reference

Header file for node_select.c. More...

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)
 

Enumerations

enum  router_crn_flags_t {
  CRN_NEED_UPTIME = 1<<0, CRN_NEED_CAPACITY = 1<<1, CRN_NEED_DESC = 1<<2, CRN_NEED_GUARD = 1<<3,
  CRN_DIRECT_CONN = 1<<4, CRN_PREF_ADDR = 1<<5, CRN_RENDEZVOUS_V3 = 1<<6, CRN_INITIATE_IPV6_EXTEND = 1<<7
}
 
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 50 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 60 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 73 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 67 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 54 of file node_select.h.

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 41 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 821 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 856 of file node_select.c.

◆ 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.

flags is a set of CRN_* flags, see router_add_running_nodes_to_smartlist() for details.

Definition at line 979 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 72 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 1051 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 1040 of file node_select.c.