41#define NODELIST_PRIVATE
85#define node_free(val) \
86 FREE_AND_NULL(node_t, node_free_, (val))
93 USABLE_DESCRIPTOR_ALL = 0U,
96 USABLE_DESCRIPTOR_EXIT_POLICY = 1U << 0,
99 USABLE_DESCRIPTOR_EXIT_FLAG = 1U << 1,
101 USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG = (USABLE_DESCRIPTOR_EXIT_POLICY |
102 USABLE_DESCRIPTOR_EXIT_FLAG)
135 address_set_t *node_addrs;
139 digestmap_t *reentry_set;
144 time_t live_consensus_valid_after;
147static inline unsigned int
148node_id_hash(
const node_t *node)
153static inline unsigned int
160HT_GENERATE2(nodelist_map,
node_t, ht_ent, node_id_hash, node_id_eq,
163static inline unsigned int
164node_ed_id_hash(
const node_t *node)
169static inline unsigned int
177HT_GENERATE2(nodelist_ed_map,
node_t, ed_ht_ent, node_ed_id_hash,
190 HT_INIT(nodelist_ed_map, &
the_nodelist->nodes_by_ed_id);
204 node = HT_FIND(nodelist_map, &
the_nodelist->nodes_by_id, &search);
219 node = HT_FIND(nodelist_ed_map, &
the_nodelist->nodes_by_ed_id, &search);
253 node = tor_malloc_zero(
sizeof(
node_t));
255 HT_INSERT(nodelist_map, &
the_nodelist->nodes_by_id, node);
279 HT_FIND(nodelist_ed_map, &
the_nodelist->nodes_by_ed_id, node);
280 if (BUG(search != node)) {
281 goto clear_and_return;
284 search = HT_REMOVE(nodelist_ed_map, &
the_nodelist->nodes_by_ed_id, node);
300 tor_asprintf(&s,
"Reused ed25519_id %s: old %s new %s", ed_id,
327 old = HT_FIND(nodelist_ed_map, &
the_nodelist->nodes_by_ed_id, node);
329 char ed_id[BASE32_BUFSIZE(
sizeof(key->pubkey))];
331 base32_encode(ed_id,
sizeof(ed_id), (
const char *)key->pubkey,
332 sizeof(key->pubkey));
333 if (BUG(old == node)) {
337 "Unexpectedly found deleted node with ed25519_id %s", ed_id);
349 HT_INSERT(nodelist_ed_map, &
the_nodelist->nodes_by_ed_id, node);
361 uint8_t *fetch_srv = NULL, *store_first_srv = NULL, *store_second_srv = NULL;
362 uint64_t next_time_period_num, current_time_period_num;
363 uint64_t fetch_tp, store_first_tp, store_second_tp;
369 static struct ratelim_t live_consensus_ratelim = RATELIM_INIT(30 * 60);
371 "Not setting hsdir index with a non-live consensus.");
376 if (node_identity_pk == NULL) {
377 log_debug(
LD_GENERAL,
"ed25519 identity public key not found when "
378 "trying to build the hsdir indexes for node %s",
388 fetch_tp = current_time_period_num;
395 store_second_tp = current_time_period_num;
399 store_first_tp = current_time_period_num;
400 store_second_tp = next_time_period_num;
410 node->hsdir_index.
fetch);
475 node->ri->ipv4_orport, 0);
478 node->ri->ipv6_orport, 0);
502 memset(data, 0,
sizeof(data));
505 memcpy(data, &addr->addr.in_addr.s_addr, 4);
508 memcpy(data, &addr->addr.in6_addr.s6_addr, 16);
519 memcpy(data + 16, &port,
sizeof(port));
526 uint16_t or_port, uint16_t dir_port)
564 if (BUG(!addr) || BUG(!port))
582 const char *id_digest;
598 *ri_old_out = node->ri;
611 const char *discard=NULL;
620 node_set_hsdir_index(node,
664 node_set_hsdir_index(node, ns);
673#define ESTIMATED_ADDRESS_PER_NODE 2
678get_estimated_address_per_node, (
void))
680 return ESTIMATED_ADDRESS_PER_NODE;
692 int authdir = authdir_mode_v3(options);
695 if (ns->
flavor == FLAV_MICRODESC)
704 get_estimated_address_per_node();
706 get_estimated_address_per_node());
717 if (ns->
flavor == FLAV_MICRODESC) {
718 if (node->md == NULL ||
724 rs->descriptor_digest);
731 if (rs->pv.supports_v3_hsdir) {
732 node_set_hsdir_index(node, ns);
740 node->is_fast = rs->is_fast;
753 } SMARTLIST_FOREACH_END(rs);
760 } SMARTLIST_FOREACH_END(node);
780 } SMARTLIST_FOREACH_END(node);
803 return (node->rs) || (node->ri);
812 if (node && node->md == md) {
826 if (node && node->ri == ri) {
842 if (remove_from_ht) {
843 tmp = HT_REMOVE(nodelist_map, &
the_nodelist->nodes_by_id, node);
871 if (node->md == md) {
874 } SMARTLIST_FOREACH_END(node);
901 for (iter = HT_START(nodelist_map, &
the_nodelist->nodes_by_id); iter; ) {
904 if (node->md && !node->rs) {
911 iter = HT_NEXT(nodelist_map, &
the_nodelist->nodes_by_id, iter);
913 iter = HT_NEXT_RMV(nodelist_map, &
the_nodelist->nodes_by_id, iter);
929 HT_CLEAR(nodelist_ed_map, &
the_nodelist->nodes_by_ed_id);
933 } SMARTLIST_FOREACH_END(node);
958 dm = digestmap_new();
968 digestmap_set(dm, node->
identity, (
void*)node);
969 } SMARTLIST_FOREACH_END(ri);
978 digestmap_set(dm, node->
identity, (
void*)node);
979 if (ns->
flavor == FLAV_MICRODESC) {
989 } SMARTLIST_FOREACH_END(rs);
997 } SMARTLIST_FOREACH_END(node);
1006 } SMARTLIST_FOREACH_END(node);
1009 HT_FOREACH(idx, nodelist_ed_map, &
the_nodelist->nodes_by_ed_id) {
1020 digestmap_free(dm, NULL);
1036 log_info(
LD_GENERAL,
"Nodelist was not fresh: rebuilding. (%d / %d)",
1070 if (nn_char ==
'=') {
1087 const int warn_if_unnamed = !(flags & NNF_NO_WARN_UNNAMED);
1105 const node_t *choice = NULL;
1110 } SMARTLIST_FOREACH_END(node);
1112 if (smartlist_len(matches)>1 && warn_if_unnamed) {
1113 int any_unwarned = 0;
1119 } SMARTLIST_FOREACH_END(node);
1122 log_warn(
LD_CONFIG,
"There are multiple matches for the name %s. "
1123 "Choosing one arbitrarily.", nickname);
1125 }
else if (smartlist_len(matches)==1 && warn_if_unnamed) {
1127 node_t *node = smartlist_get(matches, 0);
1131 "You specified a relay \"%s\" by name, but nicknames can be "
1132 "used by any relay, not just the one you meant. "
1133 "To make sure you get the same relay in the future, refer "
1134 "to it by key, as \"$%s\".", nickname, fp);
1139 if (smartlist_len(matches))
1140 choice = smartlist_get(matches, 0);
1142 smartlist_free(matches);
1175 if (ri_pk && md_pk) {
1182 "Inconsistent ed25519 identities in the nodelist");
1208 0,0,0,0,0,0,0,0,0,0,0,0,0,0
1216 return &node->rs->
pv;
1217 }
else if (node->ri) {
1218 return &node->ri->
pv;
1224 tor_assert_nonfatal_unreached_once();
1235 bool compatible_with_us))
1242 if (compatible_with_us)
1291 supports_establish_intro_dos_extension;
1308 if (!node_has_ipv6_orport(node)) {
1325 bool need_canonical_ipv6_conn)
1330 if (!node_has_ipv6_orport(node)) {
1335 if (need_canonical_ipv6_conn) {
1358 return (
const uint8_t*)node->
identity;
1375node_get_link_specifier_smartlist,(
const node_t *node,
bool direct_conn))
1377 link_specifier_t *ls;
1391 BUG(!tor_addr_port_is_valid_ap(&ap, 0))) {
1395 ls = link_specifier_new();
1396 link_specifier_set_ls_type(ls, LS_IPV4);
1398 link_specifier_set_un_ipv4_port(ls, ap.port);
1400 link_specifier_set_ls_len(ls,
sizeof(ap.addr.addr.in_addr) +
1405 ls = link_specifier_new();
1406 link_specifier_set_ls_type(ls, LS_LEGACY_ID);
1407 memcpy(link_specifier_getarray_un_legacy_id(ls), node->
identity,
1408 link_specifier_getlen_un_legacy_id(ls));
1409 link_specifier_set_ls_len(ls, link_specifier_getlen_un_legacy_id(ls));
1419 ls = link_specifier_new();
1420 link_specifier_set_ls_type(ls, LS_ED25519_ID);
1421 memcpy(link_specifier_getarray_un_ed25519_id(ls), &node->
ed25519_id,
1422 link_specifier_getlen_un_ed25519_id(ls));
1423 link_specifier_set_ls_len(ls, link_specifier_getlen_un_ed25519_id(ls));
1428 if (node_has_ipv6_orport(node)) {
1429 ls = link_specifier_new();
1431 link_specifier_set_ls_type(ls, LS_IPV6);
1432 size_t addr_len = link_specifier_getlen_un_ipv6_addr(ls);
1434 uint8_t *ipv6_array = link_specifier_getarray_un_ipv6_addr(ls);
1435 memcpy(ipv6_array,
in6_addr, addr_len);
1436 link_specifier_set_un_ipv6_port(ls, ap.port);
1438 link_specifier_set_ls_len(ls, addr_len +
sizeof(ap.port));
1447link_specifier_smartlist_free_(
smartlist_t *ls_list)
1453 link_specifier_free(lspec));
1454 smartlist_free(ls_list);
1480 return rs->is_v2_dir;
1481 }
else if (node->ri) {
1499 (node->rs && node->md));
1510 int for_direct_connect)
1515 if ((is_bridge && for_direct_connect) || !we_use_mds) {
1521 if (node->rs == NULL || node->md == NULL)
1543 char *verbose_name_out)
1546 verbose_name_out[0] =
'$';
1563 char *verbose_name_out)
1567 verbose_name_out[0] =
'$';
1579 if (node && node->ri)
1607 if (family == AF_UNSPEC) {
1610 }
else if (family == AF_INET) {
1611 return node->ri != NULL;
1612 }
else if (family == AF_INET6) {
1625#define SL_ADD_NEW_AP(r, addr_field, port_field, sl, valid) \
1627 if (tor_addr_port_is_valid(&(r)->addr_field, (r)->port_field, 0)) { \
1629 tor_addr_port_t *ap = tor_addr_port_new(&(r)->addr_field, \
1631 smartlist_add((sl), ap); \
1650 if (node->ri != NULL) {
1651 SL_ADD_NEW_AP(node->ri, ipv4_addr, ipv4_orport, sl, valid);
1655 if (!valid && node->rs != NULL) {
1656 SL_ADD_NEW_AP(node->rs, ipv4_addr, ipv4_orport, sl, valid);
1661 if (node->ri != NULL) {
1662 SL_ADD_NEW_AP(node->ri, ipv6_addr, ipv6_orport, sl, valid);
1665 if (!valid && node->rs != NULL) {
1666 SL_ADD_NEW_AP(node->rs, ipv6_addr, ipv6_orport, sl, valid);
1669 if (!valid && node->md != NULL) {
1670 SL_ADD_NEW_AP(node->md, ipv6_addr, ipv6_orport, sl, valid);
1696 if (node->ri && tor_addr_is_valid(&node->ri->
ipv4_addr, 0)) {
1698 }
else if (node->rs && tor_addr_is_valid(&node->rs->ipv4_addr, 0)) {
1699 return &node->rs->ipv4_addr;
1713 }
else if (len > 0) {
1753node_has_ipv6_addr(
const node_t *node)
1759 if (node->ri && tor_addr_is_valid(&node->ri->
ipv6_addr, 0))
1761 if (node->rs && tor_addr_is_valid(&node->rs->
ipv6_addr, 0))
1763 if (node->md && tor_addr_is_valid(&node->md->
ipv6_addr, 0))
1771node_has_ipv6_orport(
const node_t *node)
1775 return tor_addr_port_is_valid_ap(&ipv6_orport, 0);
1780node_has_ipv6_dirport(
const node_t *node)
1784 return tor_addr_port_is_valid_ap(&ipv6_dirport, 0);
1804 node_assert_ok(node);
1813 !tor_addr_port_is_valid_ap(&ipv4_addr, 0)) {
1814 return node_has_ipv6_orport(node);
1819#define RETURN_IPV4_AP(r, port_field, ap_out) \
1821 if (r && tor_addr_port_is_valid(&(r)->ipv4_addr, (r)->port_field, 0)) { \
1822 tor_addr_copy(&(ap_out)->addr, &(r)->ipv4_addr); \
1823 (ap_out)->port = (r)->port_field; \
1832 node_assert_ok(node);
1843 RETURN_IPV4_AP(node->ri, ipv4_orport, ap_out);
1844 RETURN_IPV4_AP(node->rs, ipv4_orport, ap_out);
1868 node_assert_ok(node);
1870 memset(ap_out, 0,
sizeof(*ap_out));
1878 if (node->ri && tor_addr_port_is_valid(&node->ri->
ipv6_addr,
1879 node->ri->ipv6_orport, 0)) {
1881 ap_out->port = node->ri->ipv6_orport;
1882 }
else if (node->rs && tor_addr_port_is_valid(&node->rs->
ipv6_addr,
1886 }
else if (node->md && tor_addr_port_is_valid(&node->md->
ipv6_addr,
1912 node_assert_ok(node);
1921 }
else if (!tor_addr_port_is_valid_ap(&ipv4_addr, 0)
1923 return node_has_ipv6_dirport(node);
1933 node_assert_ok(node);
1944 RETURN_IPV4_AP(node->ri, ipv4_dirport, ap_out);
1945 RETURN_IPV4_AP(node->rs, ipv4_dirport, ap_out);
1949#undef RETURN_IPV4_AP
1971 node_assert_ok(node);
1981 if (node->ri && tor_addr_port_is_valid(&node->ri->
ipv6_addr,
1982 node->ri->ipv4_dirport, 0)) {
1984 ap_out->port = node->ri->ipv4_dirport;
1985 }
else if (node->rs && tor_addr_port_is_valid(&node->rs->
ipv6_addr,
2029 if (routerinfo_has_curve25519_onion_key(node->ri))
2046 ipv4_addr = &node->rs->ipv4_addr;
2052 if (BUG(!ipv4_addr)) {
2096 if (n && nickname[0]!=
'$' && !strcasecmp(n, nickname))
2121 }
else if (n1->md) {
2139 if (node->md && node->md->
family) {
2161 } SMARTLIST_FOREACH_END(
name);
2165 if (node->md && node->md->
family) {
2201 if (routerset_contains_node(rs, node1) &&
2202 routerset_contains_node(rs, node2))
2249 } SMARTLIST_FOREACH_END(node2);
2264 } SMARTLIST_FOREACH_END(node2);
2265 smartlist_free(declared_family);
2271 if (routerset_contains_node(rs, node)) {
2272 routerset_get_all_nodes(sl, rs, NULL, 0);
2314 int need_capacity,
int need_guard)
2318 if (need_capacity && !node->is_fast)
2342 } SMARTLIST_FOREACH_END(node);
2367 log_debug(
LD_DIR,
"Marking router %s as %s.",
2371 log_warn(
LD_NET,
"We just marked ourself as down. Are your external "
2372 "addresses reachable?");
2407 static int logged_delay=0;
2408 const char *delay_fetches_msg = NULL;
2411 log_notice(
LD_DIR,
"Delaying directory fetches: %s", delay_fetches_msg);
2482 routerset_t *in_set,
2485 const int md = (consensus->
flavor == FLAV_MICRODESC);
2486 *num_present = 0, *num_usable = 0;
2494 if ((exit_only & USABLE_DESCRIPTOR_EXIT_FLAG) && ! rs->is_exit)
2499 const char *
const digest = rs->descriptor_digest;
2509 if ((exit_only & USABLE_DESCRIPTOR_EXIT_POLICY) &&
2521 SMARTLIST_FOREACH_END(rs);
2523 log_debug(
LD_DIR,
"%d usable, %d present (%s%s%s%s%s).",
2524 *num_usable, *num_present,
2525 md ?
"microdesc" :
"desc",
2526 (exit_only & USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG) ?
2528 (exit_only & USABLE_DESCRIPTOR_EXIT_POLICY) ?
2530 (exit_only == USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG) ?
2532 (exit_only & USABLE_DESCRIPTOR_EXIT_FLAG) ?
2551 int *num_present_out,
int *num_usable_out,
2557 double f_guard, f_mid, f_exit;
2558 double f_path = 0.0;
2563 const int authdir = authdir_mode_v3(options);
2567 USABLE_DESCRIPTOR_ALL);
2569 "%s: %d present, %d usable",
2578 "%s: %d present, %d usable",
2595 smartlist_len(guards));
2600 NULL, USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG);
2602 "%s: %d present, %d usable",
2612 CONSENSUS_PATH_EXIT :
2613 CONSENSUS_PATH_INTERNAL);
2618 "The current consensus has no exit nodes. "
2619 "Tor can only build internal paths, "
2620 "such as paths to onion services.");
2626 }
else if (old_have_consensus_path == CONSENSUS_PATH_INTERNAL) {
2628 "The current consensus contains exit nodes. "
2629 "Tor can build exit and internal paths.");
2643 "f_guard: %.2f, f_mid: %.2f, f_exit: %.2f",
2648 smartlist_free(guards);
2649 smartlist_free(mid);
2650 smartlist_free(exits);
2653 double f_myexit, f_myexit_unflagged;
2660 USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG);
2662 "%s: %d present, %d usable",
2672 USABLE_DESCRIPTOR_EXIT_POLICY);
2674 "%s: %d present, %d usable",
2675 "myexits_unflagged (initial)",
2682 WEIGHT_FOR_EXIT, 0);
2685 "f_exit: %.2f, f_myexit: %.2f, f_myexit_unflagged: %.2f",
2688 f_myexit_unflagged);
2693 if (smartlist_len(myexits) == 0 &&
2694 smartlist_len(myexits_unflagged)) {
2695 f_myexit = f_myexit_unflagged;
2698 smartlist_free(myexits);
2699 smartlist_free(myexits_unflagged);
2705 if (f_myexit < f_exit)
2720 if (f_exit <= 0.0) {
2725 f_path = f_guard * f_mid * f_exit;
2729 "%d%% of guards bw, "
2730 "%d%% of midpoint bw, and "
2738 "end bw (no exits in consensus, using mid)"),
2750 int num_present = 0, num_usable=0;
2751 time_t now = time(NULL);
2755 double paths, fraction;
2761 &num_present, &num_usable,
2767 return BOOTSTRAP_STATUS_LOADING_DESCRIPTORS + (int)
2768 (fraction*(BOOTSTRAP_STATUS_ENOUGH_DIRINFO-1 -
2769 BOOTSTRAP_STATUS_LOADING_DESCRIPTORS));
2778#define DFLT_PCT_USABLE_NEEDED 60
2783 DFLT_PCT_USABLE_NEEDED,
2794 time_t now = time(NULL);
2796 int num_present=0, num_usable=0;
2801 static int be_loud_when_things_work_again = 0;
2814 using_md = consensus->
flavor == FLAV_MICRODESC;
2818 char *status = NULL;
2820 &num_present, &num_usable,
2825 "We need more %sdescriptors: we have %d/%d, and "
2826 "can only build %d%% of likely paths. (We have %s.)",
2827 using_md?
"micro":
"", num_present, num_usable,
2828 (
int)(paths*100), status);
2858 "We now have enough directory information to build circuits.");
2859 be_loud_when_things_work_again = 0;
2866 "Our directory information is no longer up-to-date "
2870 be_loud_when_things_work_again = 1;
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
void tor_addr_make_null(tor_addr_t *a, sa_family_t family)
int tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2, maskbits_t mbits, tor_addr_comparison_t how)
int tor_addr_is_v4(const tor_addr_t *addr)
int tor_addr_is_null(const tor_addr_t *addr)
int tor_addr_is_v6(const tor_addr_t *addr)
const char * tor_addr_to_str(char *dest, const tor_addr_t *addr, size_t len, int decorate)
static sa_family_t tor_addr_family(const tor_addr_t *a)
static uint32_t tor_addr_to_ipv4h(const tor_addr_t *a)
#define tor_addr_to_in6_addr8(x)
#define tor_addr_from_in(dest, in)
#define tor_addr_eq(a, b)
void address_set_add(address_set_t *set, const struct tor_addr_t *addr)
int address_set_probably_contains(const address_set_t *set, const struct tor_addr_t *addr)
address_set_t * address_set_new(int max_addresses_guess)
Types to handle sets of addresses.
int authdir_mode(const or_options_t *options)
Header file for directory authority mode.
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
void base32_encode(char *dest, size_t destlen, const char *src, size_t srclen)
int node_is_a_configured_bridge(const node_t *node)
Header file for circuitbuild.c.
const or_options_t * get_options(void)
Header file for config.c.
void control_event_boot_dir(bootstrap_status_t status, int progress)
int control_event_client_status(int severity, const char *format,...)
Header file for control_events.c.
int ed25519_public_key_is_zero(const ed25519_public_key_t *pubkey)
int ed25519_pubkey_eq(const ed25519_public_key_t *key1, const ed25519_public_key_t *key2)
const char * node_describe(const node_t *node)
Header file for describe.c.
int tor_memeq(const void *a, const void *b, size_t sz)
#define fast_memeq(a, b, c)
#define tor_memneq(a, b, sz)
Trusted/fallback directory server structure.
int dirclient_too_idle_to_fetch_descriptors(const or_options_t *options, time_t now)
Header for feature/dirclient/dirclient_modes.c.
int get_n_authorities(dirinfo_type_t type)
void dirlist_add_trusted_dir_addresses(void)
Header file for dirlist.c.
int num_bridges_usable(int use_maybe_reachable)
char * entry_guards_get_err_str_if_dir_info_missing(int using_mds, int num_present, int num_usable)
Header file for circuitbuild.c.
int geoip_get_country_by_addr(const tor_addr_t *addr)
HT_PROTOTYPE(hs_circuitmap_ht, circuit_t, hs_circuitmap_node, hs_circuit_hash_token, hs_circuits_have_same_token)
void hs_client_dir_info_changed(void)
Header file containing client data for the HS subsystem.
uint64_t hs_get_time_period_num(time_t now)
uint8_t * hs_get_current_srv(uint64_t time_period_num, const networkstatus_t *ns)
uint64_t hs_get_next_time_period_num(time_t now)
uint8_t * hs_get_previous_srv(uint64_t time_period_num, const networkstatus_t *ns)
uint64_t hs_get_previous_time_period_num(time_t now)
void hs_build_hsdir_index(const ed25519_public_key_t *identity_pk, const uint8_t *srv_value, uint64_t period_num, uint8_t *hsdir_index_out)
int hs_in_period_between_tp_and_srv(const networkstatus_t *consensus, time_t now)
Header file containing common data for the whole HS subsystem.
void hs_service_dir_info_changed(void)
typedef HT_HEAD(hs_service_ht, hs_service_t) hs_service_ht
int tor_inet_aton(const char *str, struct in_addr *addr)
void tor_log(int severity, log_domain_mask_t domain, const char *format,...)
#define log_fn(severity, domain, args,...)
#define log_fn_ratelim(ratelim, severity, domain, args,...)
void note_that_we_maybe_cant_complete_circuits(void)
Header file for mainloop.c.
void * tor_reallocarray_(void *ptr, size_t sz1, size_t sz2)
void tor_free_(void *mem)
int usable_consensus_flavor(void)
microdesc_t * microdesc_cache_lookup_by_digest256(microdesc_cache_t *cache, const char *d)
microdesc_cache_t * get_microdesc_cache(void)
int we_use_microdescriptors_for_circuits(const or_options_t *options)
Header file for microdesc.c.
Microdescriptor structure.
int net_is_disabled(void)
networkstatus_t * networkstatus_get_latest_consensus_by_flavor(consensus_flavor_t f)
int networkstatus_consensus_reasonably_live(const networkstatus_t *consensus, time_t now)
networkstatus_t * networkstatus_get_reasonably_live_consensus(time_t now, int flavor)
int client_would_use_router(const routerstatus_t *rs, time_t now)
networkstatus_t * networkstatus_get_latest_consensus(void)
const routerstatus_t * router_get_consensus_status_by_descriptor_digest(networkstatus_t *consensus, const char *digest)
int networkstatus_is_live(const networkstatus_t *ns, time_t now)
int should_delay_dir_fetches(const or_options_t *options, const char **msg_out)
int32_t networkstatus_get_param(const networkstatus_t *ns, const char *param_name, int32_t default_val, int32_t min_val, int32_t max_val)
Header file for networkstatus.c.
Networkstatus consensus/vote structure.
double frac_nodes_with_descriptors(const smartlist_t *sl, bandwidth_weight_rule_t rule, int for_direct_conn)
Header file for node_select.c.
Node information structure.
bool nodefamily_contains_node(const nodefamily_t *family, const node_t *node)
void nodefamily_add_nodes_to_smartlist(const nodefamily_t *family, smartlist_t *out)
Header file for nodefamily.c.
static void node_free_(node_t *node)
const node_t * router_find_exact_exit_enclave(const char *address, uint16_t port)
static int node_add_to_ed25519_map(node_t *node)
void node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out)
bool node_supports_establish_intro_dos_extension(const node_t *node)
static nodelist_t * the_nodelist
void node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
int nodelist_probably_contains_address(const tor_addr_t *addr)
void node_get_verbose_nickname_by_id(const char *id_digest, char *verbose_name_out)
const uint8_t * node_get_rsa_id_digest(const node_t *node)
const node_t * node_get_by_id(const char *identity_digest)
static double get_frac_paths_needed_for_circs(const or_options_t *options, const networkstatus_t *ns)
static double compute_frac_paths_available(const networkstatus_t *consensus, const or_options_t *options, time_t now, int *num_present_out, int *num_usable_out, char **status_out)
static char dir_info_status[512]
void nodelist_free_all(void)
void nodelist_add_node_and_family(smartlist_t *sl, const node_t *node)
void nodelist_refresh_countries(void)
STATIC void node_lookup_declared_family(smartlist_t *out, const node_t *node)
void router_dir_info_changed(void)
const smartlist_t * nodelist_get_list(void)
int node_is_good_exit(const node_t *node)
const node_t * node_get_by_nickname(const char *nickname, unsigned flags)
static void node_add_to_address_set(const node_t *node)
void node_get_address_string(const node_t *node, char *buf, size_t len)
const char * node_get_platform(const node_t *node)
static void init_nodelist(void)
int node_exit_policy_is_exact(const node_t *node, sa_family_t family)
int router_addrs_in_same_network(const tor_addr_t *a1, const tor_addr_t *a2)
bool node_supports_accepting_ipv6_extends(const node_t *node, bool need_canonical_ipv6_conn)
static const tor_addr_t * node_get_prim_addr_ipv4(const node_t *node)
static void update_router_have_minimum_dir_info(void)
static void count_usable_descriptors(int *num_present, int *num_usable, smartlist_t *descs_out, const networkstatus_t *consensus, time_t now, routerset_t *in_set, usable_descriptor_t exit_only)
static int microdesc_has_curve25519_onion_key(const microdesc_t *md)
void node_get_pref_dirport(const node_t *node, tor_addr_port_t *ap_out)
int node_has_preferred_descriptor(const node_t *node, int for_direct_connect)
static int node_is_usable(const node_t *node)
STATIC int node_in_nickname_smartlist(const smartlist_t *lst, const node_t *node)
node_t * nodelist_set_routerinfo(routerinfo_t *ri, routerinfo_t **ri_old_out)
smartlist_t * node_get_all_orports(const node_t *node)
node_t * node_get_mutable_by_ed25519_id(const ed25519_public_key_t *ed_id)
int node_is_me(const node_t *node)
const node_t * node_get_by_ed25519_id(const ed25519_public_key_t *ed_id)
static const protover_summary_flags_t zero_protover_flags
const char * node_get_nickname(const node_t *node)
bool node_supports_conflux(const node_t *node)
int node_has_any_descriptor(const node_t *node)
void nodelist_purge(void)
node_t * nodelist_add_microdesc(microdesc_t *md)
int node_is_dir(const node_t *node)
int node_is_unreliable(const node_t *node, int need_uptime, int need_capacity, int need_guard)
smartlist_t * nodelist_find_nodes_with_microdesc(const microdesc_t *md)
bool node_supports_v3_rendezvous_point(const node_t *node)
void node_get_prim_dirport(const node_t *node, tor_addr_port_t *ap_out)
bool node_supports_ed25519_link_authentication(const node_t *node, bool compatible_with_us)
bool node_supports_v3_hsdir(const node_t *node)
static consensus_path_type_t have_consensus_path
int node_ipv6_dir_preferred(const node_t *node)
int router_exit_policy_all_nodes_reject(const tor_addr_t *addr, uint16_t port, int need_uptime)
long node_get_declared_uptime(const node_t *node)
const char * get_dir_info_status_string(void)
static void node_addrs_changed(node_t *node)
static node_t * node_get_or_create(const char *identity_digest)
consensus_path_type_t router_have_consensus_path(void)
int node_ed25519_id_matches(const node_t *node, const ed25519_public_key_t *id)
static int need_to_update_have_min_dir_info
static int have_min_dir_info
static int node_remove_from_ed25519_map(node_t *node)
void nodelist_add_addr_to_address_set(const tor_addr_t *addr, uint16_t or_port, uint16_t dir_port)
static const protover_summary_flags_t * node_get_protover_summary_flags(const node_t *node)
int node_allows_single_hop_exits(const node_t *node)
const curve25519_public_key_t * node_get_curve25519_onion_key(const node_t *node)
int node_get_purpose(const node_t *node)
void node_get_pref_ipv6_dirport(const node_t *node, tor_addr_port_t *ap_out)
const ed25519_public_key_t * node_get_ed25519_id(const node_t *node)
void nodelist_set_consensus(const networkstatus_t *ns)
bool nodelist_reentry_contains(const tor_addr_t *addr, uint16_t port)
node_t * node_get_mutable_by_id(const char *identity_digest)
void nodelist_remove_microdesc(const char *identity_digest, microdesc_t *md)
const node_t * node_get_by_hex_id(const char *hex_id, unsigned flags)
void node_set_country(node_t *node)
int node_ipv6_or_preferred(const node_t *node)
void nodelist_remove_routerinfo(routerinfo_t *ri)
void nodelist_ensure_freshness(const networkstatus_t *ns)
STATIC bool node_has_declared_family(const node_t *node)
STATIC int node_nickname_matches(const node_t *node, const char *nickname)
void node_get_addr(const node_t *node, tor_addr_t *addr_out)
static char * build_addr_port_item(const tor_addr_t *addr, const uint16_t port)
static void node_log_dup_ed_id(const node_t *old, const node_t *node, const char *ed_id)
int count_loading_descriptors_progress(void)
void node_get_verbose_nickname(const node_t *node, char *verbose_name_out)
bool node_supports_initiating_ipv6_extends(const node_t *node)
void node_get_pref_ipv6_orport(const node_t *node, tor_addr_port_t *ap_out)
STATIC int node_family_contains(const node_t *n1, const node_t *n2)
int nodes_in_same_family(const node_t *node1, const node_t *node2)
static void nodelist_drop_node(node_t *node, int remove_from_ht)
int node_has_curve25519_onion_key(const node_t *node)
int router_have_minimum_dir_info(void)
void nodelist_assert_ok(void)
int node_exit_policy_rejects_all(const node_t *node)
bool node_supports_ed25519_hs_intro(const node_t *node)
void router_set_status(const char *digest, int up)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
#define UNNAMED_ROUTER_NICKNAME
int reachable_addr_prefer_ipv6_dirport(const or_options_t *options)
int reachable_addr_prefer_ipv6_orport(const or_options_t *options)
int reachable_addr_use_ipv6(const or_options_t *options)
addr_policy_result_t compare_tor_addr_to_node_policy(const tor_addr_t *addr, uint16_t port, const node_t *node)
Header file for policies.c.
@ ADDR_POLICY_PROBABLY_REJECTED
int tor_asprintf(char **strp, const char *fmt,...)
int tor_snprintf(char *str, size_t size, const char *format,...)
void dirserv_set_node_flags_from_authoritative_status(node_t *node, uint32_t authstatus)
uint32_t dirserv_router_get_status(const routerinfo_t *router, const char **msg, int severity)
Header file for process_descs.c.
Headers and type declarations for protover.c.
int router_digest_is_me(const char *digest)
Router descriptor structure.
#define ROUTER_PURPOSE_GENERAL
int hex_digest_nickname_matches(const char *hexdigest, const char *identity_digest, const char *nickname)
routerlist_t * router_get_routerlist(void)
signed_descriptor_t * router_get_by_descriptor_digest(const char *digest)
int hex_digest_nickname_decode(const char *hexdigest, char *digest_out, char *nickname_qualifier_char_out, char *nickname_out)
int routers_have_same_or_addrs(const routerinfo_t *r1, const routerinfo_t *r2)
Header file for routerlist.c.
Router descriptor list structure.
int routerset_contains_routerstatus(const routerset_t *set, const routerstatus_t *rs, country_t country)
int routerset_contains_node(const routerset_t *set, const node_t *node)
Header file for routerset.c.
Routerstatus (consensus entry) structure.
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
void smartlist_del(smartlist_t *sl, int idx)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
uint8_t fetch[DIGEST256_LEN]
uint8_t store_first[DIGEST256_LEN]
uint8_t store_second[DIGEST256_LEN]
unsigned int held_by_nodes
struct curve25519_public_key_t * onion_curve25519_pkey
char digest[DIGEST256_LEN]
unsigned int policy_is_reject_star
struct nodefamily_t * family
struct ed25519_public_key_t * ed25519_identity_pkey
smartlist_t * routerstatus_list
consensus_flavor_t flavor
ed25519_public_key_t ed25519_id
char identity[DIGEST_LEN]
unsigned int is_possible_guard
unsigned int ipv6_preferred
unsigned int name_lookup_warned
struct routerset_t * ExcludeExitNodesUnion_
struct smartlist_t * NodeFamilySets
int EnforceDistinctSubnets
struct routerset_t * EntryNodes
struct routerset_t * ExitNodes
double PathsNeededToBuildCircuits
struct routerset_t * MiddleNodes
unsigned int supports_ed25519_link_handshake_compat
unsigned int supports_v3_rendezvous_point
unsigned int supports_initiating_ipv6_extends
unsigned int supports_v3_hsdir
unsigned int supports_ed25519_link_handshake_any
unsigned int supports_canonical_ipv6_conns
unsigned int supports_conflux
unsigned int supports_accepting_ipv6_extends
unsigned int supports_ed25519_hs_intro
unsigned int allow_single_hop_exits
protover_summary_flags_t pv
smartlist_t * declared_family
struct curve25519_public_key_t * onion_curve25519_pkey
unsigned int policy_is_reject_star
unsigned int supports_tunnelled_dir_requests
protover_summary_flags_t pv
char identity_digest[DIGEST_LEN]
char nickname[MAX_NICKNAME_LEN+1]
unsigned int is_possible_guard
char identity_digest[DIGEST_LEN]
struct tor_cert_st * signing_key_cert
#define MOCK_IMPL(rv, funcname, arglist)
#define tor_fragile_assert()
int fast_mem_is_zero(const char *mem, size_t len)
#define ED25519_PUBKEY_LEN
#define CURVE25519_PUBKEY_LEN