|
Tor 0.4.9.3-alpha-dev
|
Structures and functions for tracking what we know about the routers on the Tor network, and correlating information from networkstatus, routerinfo, and microdescs. More...
#include "core/or/or.h"#include "app/config/config.h"#include "core/mainloop/mainloop.h"#include "core/mainloop/netstatus.h"#include "core/or/address_set.h"#include "core/or/policies.h"#include "core/or/protover.h"#include "feature/client/bridges.h"#include "feature/client/entrynodes.h"#include "feature/control/control_events.h"#include "feature/dirauth/process_descs.h"#include "feature/dirclient/dirclient_modes.h"#include "feature/hs/hs_client.h"#include "feature/hs/hs_common.h"#include "feature/nodelist/describe.h"#include "feature/nodelist/dirlist.h"#include "feature/nodelist/microdesc.h"#include "feature/nodelist/networkstatus.h"#include "feature/nodelist/node_select.h"#include "feature/nodelist/nodefamily.h"#include "feature/nodelist/nodelist.h"#include "feature/nodelist/routerlist.h"#include "feature/nodelist/routerset.h"#include "feature/nodelist/torcert.h"#include "lib/encoding/binascii.h"#include "lib/err/backtrace.h"#include "lib/geoip/geoip.h"#include "lib/net/address.h"#include <string.h>#include "feature/dirauth/authmode.h"#include "feature/dirclient/dir_server_st.h"#include "feature/nodelist/microdesc_st.h"#include "feature/nodelist/networkstatus_st.h"#include "feature/nodelist/node_st.h"#include "feature/nodelist/routerinfo_st.h"#include "feature/nodelist/routerlist_st.h"#include "feature/nodelist/routerstatus_st.h"Go to the source code of this file.
Data Structures | |
| struct | nodelist_t |
Macros | |
| #define | NODELIST_PRIVATE |
| #define | node_free(val) FREE_AND_NULL(node_t, node_free_, (val)) |
| #define | ESTIMATED_ADDRESS_PER_NODE 2 |
| #define | SL_ADD_NEW_AP(r, addr_field, port_field, sl, valid) |
| #define | RETURN_IPV4_AP(r, port_field, ap_out) |
| #define | DFLT_PCT_USABLE_NEEDED 60 |
Enumerations | |
| enum | usable_descriptor_t { USABLE_DESCRIPTOR_ALL = 0U , USABLE_DESCRIPTOR_EXIT_POLICY = 1U << 0 , USABLE_DESCRIPTOR_EXIT_FLAG = 1U << 1 , USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG } |
Variables | |
| static nodelist_t * | the_nodelist =NULL |
| static int | use_family_lists = 1 |
| static int | use_family_ids = 1 |
| static const protover_summary_flags_t | zero_protover_flags |
| static int | have_min_dir_info = 0 |
| static consensus_path_type_t | have_consensus_path = CONSENSUS_PATH_UNKNOWN |
| static int | need_to_update_have_min_dir_info = 1 |
| static char | dir_info_status [512] = "" |
Structures and functions for tracking what we know about the routers on the Tor network, and correlating information from networkstatus, routerinfo, and microdescs.
The key structure here is node_t: that's the canonical way to refer to a Tor relay that we might want to build a circuit through. Every node_t has either a routerinfo_t, or a routerstatus_t from the current networkstatus consensus. If it has a routerstatus_t, it will also need to have a microdesc_t before you can use it for circuits.
The nodelist_t is a global singleton that maps identities to node_t objects. Access them with the node_get_*() functions. The nodelist_t is maintained by calls throughout the codebase
Generally, other code should not have to reach inside a node_t to see what information it has. Instead, you should call one of the many accessor functions that works on a generic node_t. If there isn't one that does what you need, it's better to make such a function, and then use it.
For historical reasons, some of the functions that select a node_t from the list of all usable node_t objects are in the routerlist.c module, since they originally selected a routerinfo_t. (TODO: They should move!)
(TODO: Perhaps someday we should abstract the remaining ways of talking about a relay to also be node_t instances. Those would be routerstatus_t as used for directory requests, and dir_server_t as used for authorities and fallback directories.)
Definition in file nodelist.c.
| #define ESTIMATED_ADDRESS_PER_NODE 2 |
Definition at line 673 of file nodelist.c.
| #define node_free | ( | val | ) | FREE_AND_NULL(node_t, node_free_, (val)) |
Definition at line 85 of file nodelist.c.
| #define NODELIST_PRIVATE |
Definition at line 41 of file nodelist.c.
| #define RETURN_IPV4_AP | ( | r, | |
| port_field, | |||
| ap_out | |||
| ) |
Definition at line 1844 of file nodelist.c.
| #define SL_ADD_NEW_AP | ( | r, | |
| addr_field, | |||
| port_field, | |||
| sl, | |||
| valid | |||
| ) |
Definition at line 1650 of file nodelist.c.
| enum usable_descriptor_t |
count_usable_descriptors counts descriptors with these flag(s)
Definition at line 91 of file nodelist.c.
|
static |
Build a construction for the reentry set consisting of an address and port pair.
If the given address is not AF_INET or AF_INET6, then the item is an array of 0s.
Return a pointer to a static buffer containing the item. Next call to this function invalidates its previous content.
Definition at line 496 of file nodelist.c.
Referenced by nodelist_add_addr_to_address_set(), and nodelist_reentry_contains().
|
static |
Return an estimate of which fraction of usable paths through the Tor network we have available for use. Count how many routers seem like ones we'd use (store this in *num_usable_out), and how many of those we have descriptors for (store this in *num_present_out.)
If **status_out is present, allocate a new string and print the available percentages of guard, middle, and exit nodes to it, noting whether there are exits in the consensus. If there are no exits in the consensus, we treat the exit fraction as 100%, but set router_have_consensus_path() so that we can only build internal paths.
Definition at line 2625 of file nodelist.c.
Referenced by count_loading_descriptors_progress(), and update_router_have_minimum_dir_info().
| int count_loading_descriptors_progress | ( | void | ) |
We just fetched a new set of descriptors. Compute how far through the "loading descriptors" bootstrapping phase we are, so we can inform the controller of our progress.
Definition at line 2824 of file nodelist.c.
Referenced by connection_edge_process_relay_cell_not_open(), handle_response_fetch_microdesc(), and load_downloaded_routers().
|
static |
Iterate over the servers listed in consensus, and count how many of them seem like ones we'd use (store this in *num_usable), and how many of those we have descriptors for (store this in *num_present).
If in_set is non-NULL, only consider those routers in in_set. If exit_only & USABLE_DESCRIPTOR_EXIT_POLICY, only consider nodes present if they have an exit policy that accepts at least one port. If exit_only & USABLE_DESCRIPTOR_EXIT_FLAG, only consider nodes usable if they have the exit flag in the consensus.
If *descs_out is present, add a node_t for each usable descriptor to it.
Definition at line 2554 of file nodelist.c.
Referenced by compute_frac_paths_available().
| const char * get_dir_info_status_string | ( | void | ) |
Return a string describing what we're missing before we have enough directory info.
Definition at line 2534 of file nodelist.c.
Referenced by directory_info_has_arrived().
| int get_estimated_address_per_node | ( | void | ) |
Definition at line 678 of file nodelist.c.
|
static |
Return the fraction of paths needed before we're willing to build circuits, as configured in options, or in the consensus ns.
Definition at line 2851 of file nodelist.c.
Referenced by count_loading_descriptors_progress(), and update_router_have_minimum_dir_info().
|
static |
Create an empty nodelist if we haven't done so already.
Definition at line 185 of file nodelist.c.
Referenced by nodelist_add_microdesc(), nodelist_get_list(), nodelist_set_consensus(), and nodelist_set_routerinfo().
| void link_specifier_smartlist_free_ | ( | smartlist_t * | ls_list | ) |
Definition at line 1472 of file nodelist.c.
|
static |
Return true iff md has a curve25519 onion key. Use node_has_curve25519_onion_key() instead of calling this directly.
Definition at line 2023 of file nodelist.c.
Referenced by node_get_curve25519_onion_key().
|
static |
Add all address information about node to the current address set (if there is one).
Definition at line 451 of file nodelist.c.
Referenced by nodelist_add_microdesc(), nodelist_set_consensus(), and nodelist_set_routerinfo().
|
static |
If node has an ed25519 id, and it is not already in the ed25519 id map, set its ed25519_id field, and add it to the ed25519 map.
Definition at line 311 of file nodelist.c.
Referenced by nodelist_add_microdesc(), nodelist_set_consensus(), and nodelist_set_routerinfo().
|
static |
Called when a node's address changes.
Definition at line 441 of file nodelist.c.
Referenced by nodelist_set_routerinfo().
| int node_allows_single_hop_exits | ( | const node_t * | node | ) |
Return true iff it seems that node allows circuits to exit through it directlry from the client.
Definition at line 1602 of file nodelist.c.
| int node_ed25519_id_matches | ( | const node_t * | node, |
| const ed25519_public_key_t * | id | ||
| ) |
Return true iff this node's Ed25519 identity matches id. (An absent Ed25519 identity matches NULL or zero.)
Definition at line 1220 of file nodelist.c.
Referenced by connection_or_check_canonicity().
Definition at line 170 of file nodelist.c.
|
inlinestatic |
Definition at line 164 of file nodelist.c.
| int node_exit_policy_is_exact | ( | const node_t * | node, |
| sa_family_t | family | ||
| ) |
Return true iff the exit policy for node is such that we can treat rejecting an address of type family unexpectedly as a sign of that node's failure.
Definition at line 1630 of file nodelist.c.
Referenced by adjust_exit_policy_from_exitpolicy_failure().
| int node_exit_policy_rejects_all | ( | const node_t * | node | ) |
Return true iff it seems that node has an exit policy that doesn't actually permit anything to exit, or we don't know its exit policy
Definition at line 1613 of file nodelist.c.
Referenced by choose_good_exit_server_general(), connection_ap_can_use_exit(), and count_usable_descriptors().
Return true iff n1's declared family contains n2.
Definition at line 2142 of file nodelist.c.
Referenced by nodelist_add_node_and_family(), and nodes_in_same_family().
|
static |
Release storage held by node
Definition at line 906 of file nodelist.c.
| void node_get_addr | ( | const node_t * | node, |
| tor_addr_t * | addr_out | ||
| ) |
Wrapper around node_get_prim_orport for backward compatibility.
Definition at line 1706 of file nodelist.c.
Referenced by guard_in_node_family(), nodelist_add_node_and_family(), and nodes_in_same_family().
| void node_get_address_string | ( | const node_t * | node, |
| char * | buf, | ||
| size_t | len | ||
| ) |
Copy a string representation of an IP address for node into the len-byte buffer at buf.
Definition at line 1732 of file nodelist.c.
Referenced by connection_ap_handshake_rewrite_and_attach().
| smartlist_t * node_get_all_orports | ( | const node_t * | node | ) |
Return list of tor_addr_port_t with all OR ports (in the sense IP addr + TCP port) for node. Caller must free all elements using tor_free() and free the list using smartlist_free().
XXX this is potentially a memory fragmentation hog – if on critical path consider the option of having the caller allocate the memory
Definition at line 1669 of file nodelist.c.
Referenced by router_get_all_orports().
| const node_t * node_get_by_ed25519_id | ( | const ed25519_public_key_t * | ed_id | ) |
Return the node_t whose ed25519 identity is ed_id, or NULL if no such node exists.
Definition at line 234 of file nodelist.c.
Referenced by nodelist_assert_ok().
| const node_t * node_get_by_hex_id | ( | const char * | hex_id, |
| unsigned | flags | ||
| ) |
Given a hex-encoded nickname of the format DIGEST, $DIGEST, $DIGEST=name, or $DIGEST~name, return the node with the matching identity digest and nickname (if any). Return NULL if no such node exists, or if hex_id is not well-formed. DOCDOC flags
Definition at line 1083 of file nodelist.c.
Referenced by getinfo_helper_dir(), handle_control_hsfetch(), handle_control_hspost(), and node_get_by_nickname().
| const node_t * node_get_by_id | ( | const char * | identity_digest | ) |
Return the node_t whose identity is identity_digest, or NULL if no such node exists.
Definition at line 226 of file nodelist.c.
Referenced by authority_certs_fetch_missing(), build_middle_exclude_list(), build_state_get_exit_node(), build_vanguard_middle_exclude_list(), circuit_discard_optional_exit_enclaves(), circuit_find_to_cannibalize(), circuit_get_nth_node(), circuit_list_path_impl(), circuit_send_first_onion_skin(), client_rendezvous_circ_has_opened(), command_process_create_cell(), compare_routerinfo_usefulness(), connection_ap_get_begincell_flags(), connection_or_check_canonicity(), control_event_guard(), count_usable_descriptors(), directory_request_set_dir_from_routerstatus(), dirserv_single_reachability_test(), entry_guard_find_node(), entry_guard_is_listed(), entry_guard_passes_filter(), entry_guard_pick_for_circuit(), fill_relay_flags(), get_node_from_intro_point(), guard_has_descriptor(), guard_in_node_family(), hs_control_desc_event_requested(), hs_pick_hsdir(), link_apconn_to_circ(), log_heartbeat(), maintain_layer2_guards(), node_get_by_hex_id(), node_get_verbose_nickname_by_id(), nodefamily_add_nodes_to_smartlist(), nodelist_add_node_and_family(), nodelist_assert_ok(), num_bridges_usable(), onion_populate_cpath(), orconn_target_get_name(), reachable_addr_choose_from_rs(), rep_hist_dump_stats(), router_supports_extrainfo(), routerlist_add_node_and_family(), setup_intro_point_exclude_list(), and upload_descriptor_to_all().
| const node_t * node_get_by_nickname | ( | const char * | nickname, |
| unsigned | flags | ||
| ) |
Given a nickname (possibly verbose, possibly a hexadecimal digest), return the corresponding node_t, or NULL if none exists. Warn the user if they have specified a router by nickname, unless the NNF_NO_WARN_UNNAMED bit is set in flags.
Definition at line 1110 of file nodelist.c.
Referenced by addressmap_clear_excluded_trackexithosts(), circuit_discard_optional_exit_enclaves(), circuit_get_open_circ_or_launch(), connection_ap_can_use_exit(), connection_ap_handshake_attach_circuit(), connection_ap_handshake_rewrite_and_attach(), get_my_declared_family(), getinfo_helper_dir(), getinfo_helper_networkstatus(), handle_control_extendcircuit(), node_lookup_declared_family_list(), and nodefamily_add_nodes_to_smartlist().
| const curve25519_public_key_t * node_get_curve25519_onion_key | ( | const node_t * | node | ) |
Return the curve25519 key of node, or NULL if none.
Definition at line 2050 of file nodelist.c.
Referenced by extend_info_from_node(), node_has_curve25519_onion_key(), node_supports_v3_rendezvous_point(), service_intro_point_new(), and setup_introduce1_data().
| long node_get_declared_uptime | ( | const node_t * | node | ) |
Return node's declared uptime, or -1 if it doesn't seem to have one.
Definition at line 1746 of file nodelist.c.
| const ed25519_public_key_t * node_get_ed25519_id | ( | const node_t * | node | ) |
Return the Ed25519 identity key for the provided node, or NULL if it doesn't have one.
Definition at line 1175 of file nodelist.c.
Referenced by extend_info_from_node(), node_add_to_ed25519_map(), node_describe(), node_ed25519_id_matches(), node_supports_ed25519_link_authentication(), and nodelist_remove_microdesc().
|
static |
Return the listed family IDs of a, if it has any.
Definition at line 2175 of file nodelist.c.
Referenced by nodelist_add_node_and_family(), and nodes_have_common_family_id().
| smartlist_t * node_get_link_specifier_smartlist | ( | const node_t * | node, |
| bool | direct_conn | ||
| ) |
Definition at line 1400 of file nodelist.c.
| node_t * node_get_mutable_by_ed25519_id | ( | const ed25519_public_key_t * | ed_id | ) |
As node_get_by_ed25519_id, but returns a non-const pointer
Definition at line 210 of file nodelist.c.
Referenced by node_get_by_ed25519_id().
| node_t * node_get_mutable_by_id | ( | const char * | identity_digest | ) |
As node_get_by_id, but returns a non-const pointer
Definition at line 197 of file nodelist.c.
Referenced by conflux_add_middles_to_exclude_list(), connection_ap_process_end_not_open(), dirserv_generate_networkstatus_vote_obj(), dirserv_orconn_tls_done(), dirserv_set_router_is_running(), hs_get_responsible_hsdirs(), launch_direct_bridge_descriptor_fetch(), learned_bridge_descriptor(), mark_all_dirservers_up(), networkstatus_getinfo_by_purpose(), node_get_by_id(), node_get_or_create(), nodelist_add_microdesc(), nodelist_remove_microdesc(), nodelist_remove_routerinfo(), and router_set_status().
| const char * node_get_nickname | ( | const node_t * | node | ) |
Return the nickname of node, or NULL if we can't find one.
Definition at line 1484 of file nodelist.c.
Referenced by connection_or_check_canonicity(), entry_guard_add_to_sample(), hs_service_dump_stats(), node_get_by_nickname(), node_get_verbose_nickname(), node_nickname_matches(), nodefamily_contains_node(), and rep_hist_dump_stats().
|
static |
Internal: return the node_t whose identity_digest is identity_digest. If none exists, create a new one, add it to the nodelist, and return it.
Requires that the nodelist be initialized.
Definition at line 246 of file nodelist.c.
Referenced by nodelist_set_consensus(), and nodelist_set_routerinfo().
| const char * node_get_platform | ( | const node_t * | node | ) |
Return node's platform string, or NULL if we don't know it.
Definition at line 1756 of file nodelist.c.
Referenced by command_process_create_cell().
| void node_get_pref_dirport | ( | const node_t * | node, |
| tor_addr_port_t * | ap_out | ||
| ) |
Copy the preferred Dir port (IP address and TCP port) for node into *ap_out.
Definition at line 1979 of file nodelist.c.
| void node_get_pref_ipv6_dirport | ( | const node_t * | node, |
| tor_addr_port_t * | ap_out | ||
| ) |
Copy the preferred IPv6 Dir port (IP address and TCP port) for node into *ap_out.
Definition at line 1994 of file nodelist.c.
Referenced by node_get_pref_dirport(), and reachable_addr_choose_from_node().
| void node_get_pref_ipv6_orport | ( | const node_t * | node, |
| tor_addr_port_t * | ap_out | ||
| ) |
Copy the preferred IPv6 OR port (IP address and TCP port) for node into *ap_out.
Definition at line 1891 of file nodelist.c.
Referenced by connection_or_check_canonicity(), node_get_pref_orport(), nodelist_add_node_and_family(), nodes_in_same_family(), and reachable_addr_choose_from_node().
| void node_get_pref_orport | ( | const node_t * | node, |
| tor_addr_port_t * | ap_out | ||
| ) |
Copy the preferred OR port (IP address and TCP port) for node into *ap_out.
Definition at line 1876 of file nodelist.c.
Referenced by rewrite_node_address_for_bridge().
|
static |
Return the IPv4 address for node, or NULL if none found.
Definition at line 1715 of file nodelist.c.
Referenced by node_get_address_string(), and router_find_exact_exit_enclave().
| void node_get_prim_dirport | ( | const node_t * | node, |
| tor_addr_port_t * | ap_out | ||
| ) |
Copy the primary (IPv4) Dir port (IP address and TCP port) for node into *ap_out.
Definition at line 1956 of file nodelist.c.
Referenced by node_get_pref_dirport(), node_ipv6_dir_preferred(), and reachable_addr_choose_from_node().
| void node_get_prim_orport | ( | const node_t * | node, |
| tor_addr_port_t * | ap_out | ||
| ) |
Copy the primary (IPv4) OR port (IP address and TCP port) for node into *ap_out.
Definition at line 1855 of file nodelist.c.
Referenced by connection_or_check_canonicity(), extend_info_from_node(), node_get_addr(), node_get_pref_orport(), node_ipv6_or_preferred(), and reachable_addr_choose_from_node().
|
static |
Return the protover_summary_flags for a given node.
Definition at line 1238 of file nodelist.c.
Referenced by node_supports_accepting_ipv6_extends(), node_supports_conflux(), node_supports_ed25519_hs_intro(), node_supports_ed25519_link_authentication(), node_supports_establish_intro_dos_extension(), node_supports_initiating_ipv6_extends(), node_supports_v3_hsdir(), and node_supports_v3_rendezvous_point().
| int node_get_purpose | ( | const node_t * | node | ) |
Return the router_purpose of node.
Definition at line 1555 of file nodelist.c.
| const uint8_t * node_get_rsa_id_digest | ( | const node_t * | node | ) |
Return the RSA ID key's SHA1 digest for the provided node.
Definition at line 1380 of file nodelist.c.
Referenced by nodefamily_contains_node().
| void node_get_verbose_nickname | ( | const node_t * | node, |
| char * | verbose_name_out | ||
| ) |
Compute the verbose ("extended") nickname of node and store it into the MAX_VERBOSE_NICKNAME_LEN+1 character buffer at verbose_name_out
Definition at line 1567 of file nodelist.c.
Referenced by circuit_list_path_impl(), control_event_guard(), getinfo_helper_format_single_entry_guard(), node_get_verbose_nickname_by_id(), and orconn_target_get_name().
| void node_get_verbose_nickname_by_id | ( | const char * | id_digest, |
| char * | verbose_name_out | ||
| ) |
Compute the verbose ("extended") nickname of node with given id_digest and store it into the MAX_VERBOSE_NICKNAME_LEN+1 character buffer at verbose_name_out
If node_get_by_id() returns NULL, base 16 encoding of id_digest is returned instead.
Definition at line 1587 of file nodelist.c.
Referenced by node_describe_longname_by_id().
| int node_has_any_descriptor | ( | const node_t * | node | ) |
Return true iff node has either kind of descriptor – that is, a routerdescriptor or a microdescriptor.
You should probably use node_has_preferred_descriptor() instead.
Definition at line 1521 of file nodelist.c.
| int node_has_curve25519_onion_key | ( | const node_t * | node | ) |
Return true iff node has a curve25519 onion key.
Definition at line 2043 of file nodelist.c.
Referenced by extend_info_from_node().
Return true iff node has declared a nonempty family.
Definition at line 2157 of file nodelist.c.
Referenced by nodelist_add_node_and_family().
| int node_has_ipv6_addr | ( | const node_t * | node | ) |
Definition at line 1778 of file nodelist.c.
| int node_has_ipv6_dirport | ( | const node_t * | node | ) |
Definition at line 1805 of file nodelist.c.
| int node_has_ipv6_orport | ( | const node_t * | node | ) |
Definition at line 1796 of file nodelist.c.
| int node_has_preferred_descriptor | ( | const node_t * | node, |
| int | for_direct_connect | ||
| ) |
Return true iff node has the kind of descriptor we would prefer to use for it, given our configuration and how we intend to use the node.
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 1534 of file nodelist.c.
Referenced by circuit_get_open_circ_or_launch(), entry_guard_pick_for_circuit(), extend_info_from_node(), frac_nodes_with_descriptors(), guard_has_descriptor(), handle_control_extendcircuit(), hs_pick_hsdir(), node_has_hsdir_index(), and onion_populate_cpath().
Definition at line 154 of file nodelist.c.
|
inlinestatic |
Definition at line 148 of file nodelist.c.
| STATIC int node_in_nickname_smartlist | ( | const smartlist_t * | lst, |
| const node_t * | node | ||
| ) |
Return true iff node is named by some nickname in lst.
Definition at line 2130 of file nodelist.c.
Referenced by node_family_list_contains().
| int node_ipv6_dir_preferred | ( | const node_t * | node | ) |
Return 1 if we prefer the IPv6 address and Dir TCP port of node, else 0.
We prefer the IPv6 address if the router has an IPv6 address, and we can use IPv6 addresses, and: i) the router has no IPv4 Dir address. or ii) our preference is for IPv6 Dir addresses.
If there is no node, use reachable_addr_prefer_ipv6_dirport().
Definition at line 1933 of file nodelist.c.
Referenced by node_get_pref_dirport(), reachable_addr_allows_node(), and reachable_addr_choose_from_node().
| int node_ipv6_or_preferred | ( | const node_t * | node | ) |
Return 1 if we prefer the IPv6 address and OR TCP port of node, else 0.
We prefer the IPv6 address if the router has an IPv6 address, and we can use IPv6 addresses, and: i) the node_t says that it prefers IPv6 or ii) the router has no IPv4 OR address.
If you don't have a node, consider looking it up. If there is no node, use reachable_addr_prefer_ipv6_orport().
Definition at line 1825 of file nodelist.c.
Referenced by node_get_pref_orport(), reachable_addr_allows_node(), and reachable_addr_choose_from_node().
| int node_is_dir | ( | const node_t * | node | ) |
Return true iff node appears to be a directory authority or directory cache
Definition at line 1498 of file nodelist.c.
Referenced by compute_weighted_bandwidths(), node_is_possible_guard(), and router_pick_directory_server_impl().
| int node_is_me | ( | const node_t * | node | ) |
Return true iff node is one representing this router.
Definition at line 1769 of file nodelist.c.
Referenced by router_set_status().
| int node_is_unreliable | ( | const node_t * | node, |
| int | need_uptime, | ||
| int | need_capacity, | ||
| int | need_guard | ||
| ) |
Return 1 if router is not suitable for these parameters, else 0. If need_uptime is non-zero, we require a minimum uptime. If need_capacity is non-zero, we require a minimum advertised bandwidth. If need_guard, we require that the router is a possible entry guard.
Definition at line 2389 of file nodelist.c.
Referenced by router_exit_policy_all_nodes_reject().
|
inlinestatic |
Helper: return true iff a node has a usable amount of information
Definition at line 826 of file nodelist.c.
Referenced by nodelist_purge(), and nodelist_remove_routerinfo().
|
static |
Helper function to log details of duplicated ed2559_ids
Definition at line 295 of file nodelist.c.
Referenced by node_add_to_ed25519_map().
| STATIC void node_lookup_declared_family_list | ( | smartlist_t * | out, |
| const node_t * | node | ||
| ) |
Add to out every node_t that is listed by node as being in its family. (Note that these nodes are not in node's family unless they also agree that node is in their family.)
Definition at line 2209 of file nodelist.c.
Referenced by nodelist_add_node_and_family().
Return true if node's nickname matches nickname (case-insensitive), or if node's identity key digest matches a hexadecimal value stored in nickname. Return false otherwise.
Definition at line 2118 of file nodelist.c.
Referenced by node_in_nickname_smartlist().
|
static |
Remove node from the ed25519 map (if it present), and set its ed25519_id field to zero.
Definition at line 268 of file nodelist.c.
Referenced by nodelist_add_microdesc(), nodelist_drop_node(), nodelist_remove_microdesc(), nodelist_set_consensus(), and nodelist_set_routerinfo().
| void node_set_country | ( | node_t * | node | ) |
Refresh the country code of ri. This function MUST be called on each router when the GeoIP database is reloaded, and on all new routers.
Definition at line 2065 of file nodelist.c.
Referenced by nodelist_refresh_countries(), nodelist_set_consensus(), and nodelist_set_routerinfo().
| STATIC void node_set_hsdir_index | ( | node_t * | node, |
| const networkstatus_t * | ns | ||
| ) |
Definition at line 357 of file nodelist.c.
| bool node_supports_accepting_ipv6_extends | ( | const node_t * | node, |
| bool | need_canonical_ipv6_conn | ||
| ) |
Return true iff node can accept IPv6 extends (Relay=2 or Relay=3) from other relays. If need_canonical_ipv6_conn is true, also check if the relay supports canonical IPv6 connections (Relay=3 only).
This check should only be performed by client path selection code.
Definition at line 1349 of file nodelist.c.
| bool node_supports_conflux | ( | const node_t * | node | ) |
Return true iff the given node supports conflux (Relay=5)
Definition at line 1371 of file nodelist.c.
| bool node_supports_ed25519_hs_intro | ( | const node_t * | node | ) |
Return true iff node supports ed25519 authentication as an hidden service introduction point.
Definition at line 1286 of file nodelist.c.
Referenced by service_intro_point_new().
| bool node_supports_ed25519_link_authentication | ( | const node_t * | node, |
| bool | compatible_with_us | ||
| ) |
Return true iff node supports authenticating itself by ed25519 ID during the link handshake. If compatible_with_us, it needs to be using a link authentication method that we understand. If not, any plausible link authentication method will do.
Definition at line 1260 of file nodelist.c.
Referenced by connection_or_check_canonicity(), dirserv_orconn_tls_done(), dirserv_single_reachability_test(), and extend_info_from_node().
| bool node_supports_establish_intro_dos_extension | ( | const node_t * | node | ) |
Return true iff node supports the DoS ESTABLISH_INTRO cell extension.
Definition at line 1311 of file nodelist.c.
Referenced by service_intro_point_new().
| bool node_supports_initiating_ipv6_extends | ( | const node_t * | node | ) |
Return true iff node can initiate IPv6 extends (Relay=3).
This check should only be performed by client path selection code.
Extending relays should check their own IPv6 support using router_can_extend_over_ipv6(). Like other extends, they should not verify the link specifiers in the extend cell against the consensus, because it may be out of date.
Definition at line 1328 of file nodelist.c.
| bool node_supports_v3_hsdir | ( | const node_t * | node | ) |
Return true iff node supports the hidden service directory version 3 protocol (proposal 224).
Definition at line 1276 of file nodelist.c.
Referenced by hs_get_responsible_hsdirs(), and node_has_hsdir_index().
| bool node_supports_v3_rendezvous_point | ( | const node_t * | node | ) |
Return true iff node can be a rendezvous point for hidden service version 3 (HSRend=2).
Definition at line 1296 of file nodelist.c.
Referenced by client_rendezvous_circ_has_opened().
| void nodelist_add_addr_to_address_set | ( | const tor_addr_t * | addr, |
| uint16_t | or_port, | ||
| uint16_t | dir_port | ||
| ) |
Add the given address into the nodelist address set.
Definition at line 525 of file nodelist.c.
Referenced by add_trusted_dir_to_nodelist_addr_set(), and node_add_to_address_set().
| node_t * nodelist_add_microdesc | ( | microdesc_t * | md | ) |
Set the appropriate node_t to use md as its microdescriptor.
Called when a new microdesc has arrived and the usable consensus flavor is "microdesc".
Definition at line 635 of file nodelist.c.
Referenced by microdescs_add_list_to_cache().
| void nodelist_add_node_and_family | ( | smartlist_t * | sl, |
| const node_t * | node | ||
| ) |
Add all the family of node, including node itself, to the smartlist sl.
This is used to make sure we don't pick siblings in a single path, or pick more than one relay from a family for our entry guard list. Note that a node may be added to sl more than once if it is part of node's family for more than one reason.
Definition at line 2285 of file nodelist.c.
Referenced by build_middle_exclude_list(), choose_good_entry_server(), and routerlist_add_node_and_family().
| void nodelist_assert_ok | ( | void | ) |
Check that the nodelist is internally consistent, and consistent with the directory info it's derived from.
Definition at line 974 of file nodelist.c.
Referenced by dirserv_compute_performance_thresholds(), and nodelist_purge().
|
static |
Remove node from the nodelist. (Asserts that it was there to begin with.)
Definition at line 863 of file nodelist.c.
Referenced by nodelist_purge(), and nodelist_remove_routerinfo().
| void nodelist_ensure_freshness | ( | const networkstatus_t * | ns | ) |
Ensure that the nodelist has been created with the most recent consensus. If that's not the case, make it so.
Definition at line 1051 of file nodelist.c.
Referenced by hs_get_responsible_hsdirs().
| smartlist_t * nodelist_find_nodes_with_microdesc | ( | const microdesc_t * | md | ) |
Return a newly allocated smartlist of the nodes that have md as their microdescriptor.
Definition at line 888 of file nodelist.c.
Referenced by microdesc_cache_clean().
| void nodelist_free_all | ( | void | ) |
Release all storage held by the nodelist.
Definition at line 948 of file nodelist.c.
Referenced by tor_free_all().
| const smartlist_t * nodelist_get_list | ( | void | ) |
Return a list of a node_t * for every node we know about. The caller MUST NOT modify the list. (You can set and clear flags in the nodes if you must, but you must not add or remove nodes.)
Definition at line 1072 of file nodelist.c.
Referenced by choose_good_exit_server_general(), choose_guard_selection(), directory_remove_invalid(), dirserv_compute_performance_thresholds(), get_eligible_guards(), getinfo_helper_dir(), microdesc_check_counts(), microdesc_free_(), networkstatus_reset_warnings(), nodelist_add_node_and_family(), nodelist_refresh_countries(), nodelist_subtract(), onion_pick_cpath_exit(), router_add_running_nodes_to_smartlist(), router_exit_policy_all_nodes_reject(), router_find_exact_exit_enclave(), and router_pick_directory_server_impl().
| int nodelist_probably_contains_address | ( | const tor_addr_t * | addr | ) |
Return true if addr is the address of some node in the nodelist. If not, probably return false.
Definition at line 548 of file nodelist.c.
Referenced by connection_dir_is_global_write_low().
| void nodelist_purge | ( | void | ) |
Remove all entries from the nodelist that don't have enough info to be usable for anything.
Definition at line 919 of file nodelist.c.
Referenced by nodelist_set_consensus().
| bool nodelist_reentry_contains | ( | const tor_addr_t * | addr, |
| uint16_t | port | ||
| ) |
Return true if addr is the address of some node in the nodelist and corresponds also to the given port. If not, probably return false.
Definition at line 562 of file nodelist.c.
Referenced by connection_ap_handshake_rewrite_and_attach(), and connection_exit_connect().
| void nodelist_refresh_countries | ( | void | ) |
Set the country code of all routers in the routerlist.
Definition at line 2086 of file nodelist.c.
Referenced by refresh_all_country_info().
| void nodelist_remove_microdesc | ( | const char * | identity_digest, |
| microdesc_t * | md | ||
| ) |
Tell the nodelist that md is no longer a microdescriptor for the node with identity_digest.
Definition at line 834 of file nodelist.c.
| void nodelist_remove_routerinfo | ( | routerinfo_t * | ri | ) |
Tell the nodelist that ri is no longer in the routerlist.
Definition at line 848 of file nodelist.c.
Referenced by routerlist_remove().
| void nodelist_set_consensus | ( | const networkstatus_t * | ns | ) |
Tell the nodelist that the current usable consensus is ns. This makes the nodelist change all of the routerstatus entries for the nodes, drop nodes that no longer have enough info to get used, and grab microdescriptors into nodes as appropriate.
Definition at line 715 of file nodelist.c.
Referenced by nodelist_ensure_freshness().
| node_t * nodelist_set_routerinfo | ( | routerinfo_t * | ri, |
| routerinfo_t ** | ri_old_out | ||
| ) |
Add ri to an appropriate node in the nodelist. If we replace an old routerinfo, and ri_old_out is not NULL, set *ri_old_out to the previous routerinfo.
Definition at line 579 of file nodelist.c.
Referenced by routerlist_insert(), and routerlist_replace().
|
static |
Update consensus parameters relevant to nodelist operations.
We need to cache these values rather than searching for them every time we check whether two relays are in the same family.
Definition at line 701 of file nodelist.c.
Referenced by nodelist_set_consensus().
Return true iff a and b have any family ID in common.
Definition at line 2190 of file nodelist.c.
Referenced by nodelist_add_node_and_family(), and nodes_in_same_family().
Return true iff r1 and r2 are in the same family, but not the same router.
Definition at line 2230 of file nodelist.c.
Referenced by circuit_find_to_cannibalize(), and guard_in_node_family().
| int router_addrs_in_same_network | ( | const tor_addr_t * | a1, |
| const tor_addr_t * | a2 | ||
| ) |
Return true iff router1 and router2 have similar enough network addresses that we should treat them as being in the same family
Definition at line 2096 of file nodelist.c.
Referenced by guard_in_node_family(), nodelist_add_node_and_family(), and nodes_in_same_family().
| void router_dir_info_changed | ( | void | ) |
Called when our internal view of the directory has changed. This can be when the authorities change, networkstatuses change, the list of routerdescs changes, or number of running routers changes.
Definition at line 2524 of file nodelist.c.
Referenced by check_expired_networkstatus_callback(), clear_dir_servers(), dir_server_add(), entry_guards_changed_for_guard_selection(), entry_guards_note_guard_failure(), entry_guards_note_guard_success(), mark_all_dirservers_up(), microdescs_add_list_to_cache(), networkstatus_set_current_consensus(), options_act(), router_set_status(), routerlist_insert(), routerlist_remove(), routerlist_replace(), and routers_update_status_from_consensus_networkstatus().
| int router_exit_policy_all_nodes_reject | ( | const tor_addr_t * | addr, |
| uint16_t | port, | ||
| int | need_uptime | ||
| ) |
Return 1 if all running sufficiently-stable routers we can use will reject addr:port. Return 0 if any might accept it.
Definition at line 2404 of file nodelist.c.
Referenced by circuit_get_open_circ_or_launch().
| const node_t * router_find_exact_exit_enclave | ( | const char * | address, |
| uint16_t | port | ||
| ) |
Find a router that's up, that has this IP address, and that allows exit to this address:port, or return NULL if there isn't a good one. Don't exit enclave to excluded relays – it wouldn't actually hurt anything, but this way there are fewer confused users.
Definition at line 2361 of file nodelist.c.
Referenced by connection_ap_handshake_rewrite_and_attach().
| consensus_path_type_t router_have_consensus_path | ( | void | ) |
Set to CONSENSUS_PATH_EXIT if there is at least one exit node in the consensus. We update this flag in compute_frac_paths_available if there is at least one relay that has an Exit flag in the consensus. Used to avoid building exit circuits when they will almost certainly fail. Set to CONSENSUS_PATH_INTERNAL if there are no exits in the consensus. (This situation typically occurs during bootstrap of a test network.) Set to CONSENSUS_PATH_UNKNOWN if we have never checked, or have reason to believe our last known value was invalid or has expired. If we're in a network with TestingDirAuthVoteExit set, this can cause router_have_consensus_path() to be set to CONSENSUS_PATH_EXIT, even if there are no nodes with accept exit policies.
Definition at line 2514 of file nodelist.c.
Referenced by circuit_build_needed_circs(), circuit_predict_and_launch_new(), compute_frac_paths_available(), conflux_predict_new(), and run_build_circuit_event().
| int router_have_minimum_dir_info | ( | void | ) |
Return true iff we have enough consensus information to start building circuits. Right now, this means "a consensus that's less than a day old, and at least 60% of router descriptors (configurable), weighted by bandwidth. Treat the exit fraction as 100% if there are no exits in the consensus." To obtain the final weighted bandwidth, we multiply the weighted bandwidth fraction for each position (guard, middle, exit).
Definition at line 2481 of file nodelist.c.
Referenced by can_client_refetch_desc(), check_expired_networkstatus_callback(), circuit_get_open_circ_or_launch(), circuit_launch_by_extend_info(), directory_info_has_arrived(), getinfo_helper_events(), launch_descriptor_downloads(), launch_descriptor_fetches_callback(), maintain_layer2_guards(), onion_extend_cpath(), second_elapsed_callback(), should_service_upload_descriptor(), and update_extrainfo_downloads().
| void router_set_status | ( | const char * | digest, |
| int | up | ||
| ) |
Mark the router with ID digest as running or non-running in our routerlist.
Definition at line 2425 of file nodelist.c.
Referenced by channel_do_open_actions(), connection_dir_client_request_failed(), and learned_bridge_descriptor().
|
static |
Change the value of have_min_dir_info, setting it true iff we have enough network and router information to build circuits. Clear the value of need_to_update_have_min_dir_info.
Definition at line 2868 of file nodelist.c.
Referenced by router_have_minimum_dir_info().
|
static |
String describing what we're missing before we have enough directory info.
Definition at line 2471 of file nodelist.c.
Referenced by get_dir_info_status_string(), router_have_minimum_dir_info(), and update_router_have_minimum_dir_info().
|
static |
Does the consensus contain nodes that can exit?
Definition at line 2463 of file nodelist.c.
Referenced by compute_frac_paths_available(), router_have_consensus_path(), and update_router_have_minimum_dir_info().
|
static |
True iff, the last time we checked whether we had enough directory info to build circuits, the answer was "yes". If there are no exits in the consensus, we act as if we have 100% of the exit directory info.
Definition at line 2460 of file nodelist.c.
Referenced by router_have_minimum_dir_info(), and update_router_have_minimum_dir_info().
|
static |
True iff enough has changed since the last time we checked whether we had enough directory info to build circuits that our old answer can no longer be trusted.
Definition at line 2468 of file nodelist.c.
Referenced by router_dir_info_changed(), router_have_minimum_dir_info(), and update_router_have_minimum_dir_info().
|
static |
The global nodelist.
Definition at line 181 of file nodelist.c.
Referenced by init_nodelist(), node_add_to_address_set(), node_add_to_ed25519_map(), node_get_by_nickname(), node_get_mutable_by_ed25519_id(), node_get_mutable_by_id(), node_get_or_create(), node_remove_from_ed25519_map(), nodelist_add_addr_to_address_set(), nodelist_assert_ok(), nodelist_drop_node(), nodelist_ensure_freshness(), nodelist_find_nodes_with_microdesc(), nodelist_free_all(), nodelist_get_list(), nodelist_probably_contains_address(), nodelist_purge(), nodelist_reentry_contains(), and nodelist_set_consensus().
|
static |
If true, we use relays' validated family IDs in order to determine which relays are in the same family.
Definition at line 692 of file nodelist.c.
Referenced by nodelist_add_node_and_family(), nodelist_update_consensus_params(), and nodes_in_same_family().
|
static |
If true, we use relays' listed family members in order to determine which relays are in the same family.
Definition at line 687 of file nodelist.c.
Referenced by nodelist_add_node_and_family(), nodelist_update_consensus_params(), and nodes_in_same_family().
|
static |
Dummy object that should be unreturnable. Used to ensure that node_get_protover_summary_flags() always returns non-NULL.
Definition at line 1232 of file nodelist.c.
Referenced by node_get_protover_summary_flags().