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)
124 HT_HEAD(nodelist_map,
node_t) nodes_by_id;
132 HT_HEAD(nodelist_ed_map,
node_t) nodes_by_ed_id;
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
159HT_PROTOTYPE(nodelist_map,
node_t, ht_ent, node_id_hash, node_id_eq);
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
175HT_PROTOTYPE(nodelist_ed_map,
node_t, ed_ht_ent, node_ed_id_hash,
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;
718 int authdir = authdir_mode_v3(options);
721 if (ns->
flavor == FLAV_MICRODESC)
732 get_estimated_address_per_node();
734 get_estimated_address_per_node());
745 if (ns->
flavor == FLAV_MICRODESC) {
746 if (node->md == NULL ||
752 rs->descriptor_digest);
759 if (rs->pv.supports_v3_hsdir) {
760 node_set_hsdir_index(node, ns);
768 node->is_fast = rs->is_fast;
787 } SMARTLIST_FOREACH_END(rs);
794 } SMARTLIST_FOREACH_END(node);
814 } SMARTLIST_FOREACH_END(node);
828 return (node->rs) || (node->ri);
837 if (node && node->md == md) {
851 if (node && node->ri == ri) {
867 if (remove_from_ht) {
868 tmp = HT_REMOVE(nodelist_map, &
the_nodelist->nodes_by_id, node);
896 if (node->md == md) {
899 } SMARTLIST_FOREACH_END(node);
926 for (iter = HT_START(nodelist_map, &
the_nodelist->nodes_by_id); iter; ) {
929 if (node->md && !node->rs) {
936 iter = HT_NEXT(nodelist_map, &
the_nodelist->nodes_by_id, iter);
938 iter = HT_NEXT_RMV(nodelist_map, &
the_nodelist->nodes_by_id, iter);
954 HT_CLEAR(nodelist_ed_map, &
the_nodelist->nodes_by_ed_id);
958 } SMARTLIST_FOREACH_END(node);
983 dm = digestmap_new();
993 digestmap_set(dm, node->
identity, (
void*)node);
994 } SMARTLIST_FOREACH_END(ri);
1003 digestmap_set(dm, node->
identity, (
void*)node);
1004 if (ns->
flavor == FLAV_MICRODESC) {
1014 } SMARTLIST_FOREACH_END(rs);
1022 } SMARTLIST_FOREACH_END(node);
1031 } SMARTLIST_FOREACH_END(node);
1034 HT_FOREACH(idx, nodelist_ed_map, &
the_nodelist->nodes_by_ed_id) {
1045 digestmap_free(dm, NULL);
1061 log_info(
LD_GENERAL,
"Nodelist was not fresh: rebuilding. (%d / %d)",
1095 if (nn_char ==
'=') {
1112 const int warn_if_unnamed = !(flags & NNF_NO_WARN_UNNAMED);
1130 const node_t *choice = NULL;
1135 } SMARTLIST_FOREACH_END(node);
1137 if (smartlist_len(matches)>1 && warn_if_unnamed) {
1138 int any_unwarned = 0;
1144 } SMARTLIST_FOREACH_END(node);
1147 log_warn(
LD_CONFIG,
"There are multiple matches for the name %s. "
1148 "Choosing one arbitrarily.", nickname);
1150 }
else if (smartlist_len(matches)==1 && warn_if_unnamed) {
1152 node_t *node = smartlist_get(matches, 0);
1156 "You specified a relay \"%s\" by name, but nicknames can be "
1157 "used by any relay, not just the one you meant. "
1158 "To make sure you get the same relay in the future, refer "
1159 "to it by key, as \"$%s\".", nickname, fp);
1164 if (smartlist_len(matches))
1165 choice = smartlist_get(matches, 0);
1167 smartlist_free(matches);
1200 if (ri_pk && md_pk) {
1207 "Inconsistent ed25519 identities in the nodelist");
1233 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
1241 return &node->rs->
pv;
1242 }
else if (node->ri) {
1243 return &node->ri->
pv;
1249 tor_assert_nonfatal_unreached_once();
1260 bool compatible_with_us))
1267 if (compatible_with_us)
1316 supports_establish_intro_dos_extension;
1333 if (!node_has_ipv6_orport(node)) {
1350 bool need_canonical_ipv6_conn)
1355 if (!node_has_ipv6_orport(node)) {
1360 if (need_canonical_ipv6_conn) {
1383 return (
const uint8_t*)node->
identity;
1400node_get_link_specifier_smartlist,(
const node_t *node,
bool direct_conn))
1402 link_specifier_t *ls;
1416 BUG(!tor_addr_port_is_valid_ap(&ap, 0))) {
1420 ls = link_specifier_new();
1421 link_specifier_set_ls_type(ls, LS_IPV4);
1423 link_specifier_set_un_ipv4_port(ls, ap.port);
1425 link_specifier_set_ls_len(ls,
sizeof(ap.addr.addr.in_addr) +
1430 ls = link_specifier_new();
1431 link_specifier_set_ls_type(ls, LS_LEGACY_ID);
1432 memcpy(link_specifier_getarray_un_legacy_id(ls), node->
identity,
1433 link_specifier_getlen_un_legacy_id(ls));
1434 link_specifier_set_ls_len(ls, link_specifier_getlen_un_legacy_id(ls));
1444 ls = link_specifier_new();
1445 link_specifier_set_ls_type(ls, LS_ED25519_ID);
1446 memcpy(link_specifier_getarray_un_ed25519_id(ls), &node->
ed25519_id,
1447 link_specifier_getlen_un_ed25519_id(ls));
1448 link_specifier_set_ls_len(ls, link_specifier_getlen_un_ed25519_id(ls));
1453 if (node_has_ipv6_orport(node)) {
1454 ls = link_specifier_new();
1456 link_specifier_set_ls_type(ls, LS_IPV6);
1457 size_t addr_len = link_specifier_getlen_un_ipv6_addr(ls);
1459 uint8_t *ipv6_array = link_specifier_getarray_un_ipv6_addr(ls);
1460 memcpy(ipv6_array,
in6_addr, addr_len);
1461 link_specifier_set_un_ipv6_port(ls, ap.port);
1463 link_specifier_set_ls_len(ls, addr_len +
sizeof(ap.port));
1472link_specifier_smartlist_free_(
smartlist_t *ls_list)
1478 link_specifier_free(lspec));
1479 smartlist_free(ls_list);
1505 return rs->is_v2_dir;
1506 }
else if (node->ri) {
1524 (node->rs && node->md));
1535 int for_direct_connect)
1540 if ((is_bridge && for_direct_connect) || !we_use_mds) {
1546 if (node->rs == NULL || node->md == NULL)
1568 char *verbose_name_out)
1571 verbose_name_out[0] =
'$';
1588 char *verbose_name_out)
1592 verbose_name_out[0] =
'$';
1604 if (node && node->ri)
1632 if (family == AF_UNSPEC) {
1635 }
else if (family == AF_INET) {
1636 return node->ri != NULL;
1637 }
else if (family == AF_INET6) {
1650#define SL_ADD_NEW_AP(r, addr_field, port_field, sl, valid) \
1652 if (tor_addr_port_is_valid(&(r)->addr_field, (r)->port_field, 0)) { \
1654 tor_addr_port_t *ap = tor_addr_port_new(&(r)->addr_field, \
1656 smartlist_add((sl), ap); \
1675 if (node->ri != NULL) {
1676 SL_ADD_NEW_AP(node->ri, ipv4_addr, ipv4_orport, sl, valid);
1680 if (!valid && node->rs != NULL) {
1681 SL_ADD_NEW_AP(node->rs, ipv4_addr, ipv4_orport, sl, valid);
1686 if (node->ri != NULL) {
1687 SL_ADD_NEW_AP(node->ri, ipv6_addr, ipv6_orport, sl, valid);
1690 if (!valid && node->rs != NULL) {
1691 SL_ADD_NEW_AP(node->rs, ipv6_addr, ipv6_orport, sl, valid);
1694 if (!valid && node->md != NULL) {
1695 SL_ADD_NEW_AP(node->md, ipv6_addr, ipv6_orport, sl, valid);
1721 if (node->ri && tor_addr_is_valid(&node->ri->
ipv4_addr, 0)) {
1723 }
else if (node->rs && tor_addr_is_valid(&node->rs->ipv4_addr, 0)) {
1724 return &node->rs->ipv4_addr;
1738 }
else if (len > 0) {
1778node_has_ipv6_addr(
const node_t *node)
1784 if (node->ri && tor_addr_is_valid(&node->ri->
ipv6_addr, 0))
1786 if (node->rs && tor_addr_is_valid(&node->rs->
ipv6_addr, 0))
1788 if (node->md && tor_addr_is_valid(&node->md->
ipv6_addr, 0))
1796node_has_ipv6_orport(
const node_t *node)
1800 return tor_addr_port_is_valid_ap(&ipv6_orport, 0);
1805node_has_ipv6_dirport(
const node_t *node)
1809 return tor_addr_port_is_valid_ap(&ipv6_dirport, 0);
1829 node_assert_ok(node);
1838 !tor_addr_port_is_valid_ap(&ipv4_addr, 0)) {
1839 return node_has_ipv6_orport(node);
1844#define RETURN_IPV4_AP(r, port_field, ap_out) \
1846 if (r && tor_addr_port_is_valid(&(r)->ipv4_addr, (r)->port_field, 0)) { \
1847 tor_addr_copy(&(ap_out)->addr, &(r)->ipv4_addr); \
1848 (ap_out)->port = (r)->port_field; \
1857 node_assert_ok(node);
1868 RETURN_IPV4_AP(node->ri, ipv4_orport, ap_out);
1869 RETURN_IPV4_AP(node->rs, ipv4_orport, ap_out);
1893 node_assert_ok(node);
1895 memset(ap_out, 0,
sizeof(*ap_out));
1903 if (node->ri && tor_addr_port_is_valid(&node->ri->
ipv6_addr,
1904 node->ri->ipv6_orport, 0)) {
1906 ap_out->port = node->ri->ipv6_orport;
1907 }
else if (node->rs && tor_addr_port_is_valid(&node->rs->
ipv6_addr,
1911 }
else if (node->md && tor_addr_port_is_valid(&node->md->
ipv6_addr,
1937 node_assert_ok(node);
1946 }
else if (!tor_addr_port_is_valid_ap(&ipv4_addr, 0)
1948 return node_has_ipv6_dirport(node);
1958 node_assert_ok(node);
1969 RETURN_IPV4_AP(node->ri, ipv4_dirport, ap_out);
1970 RETURN_IPV4_AP(node->rs, ipv4_dirport, ap_out);
1974#undef RETURN_IPV4_AP
1996 node_assert_ok(node);
2006 if (node->ri && tor_addr_port_is_valid(&node->ri->
ipv6_addr,
2007 node->ri->ipv4_dirport, 0)) {
2009 ap_out->port = node->ri->ipv4_dirport;
2010 }
else if (node->rs && tor_addr_port_is_valid(&node->rs->
ipv6_addr,
2054 if (routerinfo_has_curve25519_onion_key(node->ri))
2071 ipv4_addr = &node->rs->ipv4_addr;
2077 if (BUG(!ipv4_addr)) {
2121 if (n && nickname[0]!=
'$' && !strcasecmp(n, nickname))
2146 }
else if (n1->md) {
2164 if (node->md && node->md->
family) {
2179 }
else if (node->md && node->md->
family_ids) {
2194 if (ids_a == NULL || ids_b == NULL)
2218 } SMARTLIST_FOREACH_END(
name);
2222 if (node->md && node->md->
family) {
2266 if (routerset_contains_node(rs, node1) &&
2267 routerset_contains_node(rs, node2))
2314 } SMARTLIST_FOREACH_END(node2);
2330 } SMARTLIST_FOREACH_END(node2);
2331 smartlist_free(declared_family);
2347 if (routerset_contains_node(rs, node)) {
2348 routerset_get_all_nodes(sl, rs, NULL, 0);
2390 int need_capacity,
int need_guard)
2394 if (need_capacity && !node->is_fast)
2418 } SMARTLIST_FOREACH_END(node);
2443 log_debug(
LD_DIR,
"Marking router %s as %s.",
2447 log_warn(
LD_NET,
"We just marked ourself as down. Are your external "
2448 "addresses reachable?");
2483 static int logged_delay=0;
2484 const char *delay_fetches_msg = NULL;
2487 log_notice(
LD_DIR,
"Delaying directory fetches: %s", delay_fetches_msg);
2558 routerset_t *in_set,
2561 const int md = (consensus->
flavor == FLAV_MICRODESC);
2562 *num_present = 0, *num_usable = 0;
2570 if ((exit_only & USABLE_DESCRIPTOR_EXIT_FLAG) && ! rs->is_exit)
2575 const char *
const digest = rs->descriptor_digest;
2585 if ((exit_only & USABLE_DESCRIPTOR_EXIT_POLICY) &&
2597 SMARTLIST_FOREACH_END(rs);
2599 log_debug(
LD_DIR,
"%d usable, %d present (%s%s%s%s%s).",
2600 *num_usable, *num_present,
2601 md ?
"microdesc" :
"desc",
2602 (exit_only & USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG) ?
2604 (exit_only & USABLE_DESCRIPTOR_EXIT_POLICY) ?
2606 (exit_only == USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG) ?
2608 (exit_only & USABLE_DESCRIPTOR_EXIT_FLAG) ?
2627 int *num_present_out,
int *num_usable_out,
2633 double f_guard, f_mid, f_exit;
2634 double f_path = 0.0;
2639 const int authdir = authdir_mode_v3(options);
2643 USABLE_DESCRIPTOR_ALL);
2645 "%s: %d present, %d usable",
2654 "%s: %d present, %d usable",
2671 smartlist_len(guards));
2676 NULL, USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG);
2678 "%s: %d present, %d usable",
2688 CONSENSUS_PATH_EXIT :
2689 CONSENSUS_PATH_INTERNAL);
2694 "The current consensus has no exit nodes. "
2695 "Tor can only build internal paths, "
2696 "such as paths to onion services.");
2702 }
else if (old_have_consensus_path == CONSENSUS_PATH_INTERNAL) {
2704 "The current consensus contains exit nodes. "
2705 "Tor can build exit and internal paths.");
2719 "f_guard: %.2f, f_mid: %.2f, f_exit: %.2f",
2724 smartlist_free(guards);
2725 smartlist_free(mid);
2726 smartlist_free(exits);
2729 double f_myexit, f_myexit_unflagged;
2736 USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG);
2738 "%s: %d present, %d usable",
2748 USABLE_DESCRIPTOR_EXIT_POLICY);
2750 "%s: %d present, %d usable",
2751 "myexits_unflagged (initial)",
2758 WEIGHT_FOR_EXIT, 0);
2761 "f_exit: %.2f, f_myexit: %.2f, f_myexit_unflagged: %.2f",
2764 f_myexit_unflagged);
2769 if (smartlist_len(myexits) == 0 &&
2770 smartlist_len(myexits_unflagged)) {
2771 f_myexit = f_myexit_unflagged;
2774 smartlist_free(myexits);
2775 smartlist_free(myexits_unflagged);
2781 if (f_myexit < f_exit)
2796 if (f_exit <= 0.0) {
2801 f_path = f_guard * f_mid * f_exit;
2805 "%d%% of guards bw, "
2806 "%d%% of midpoint bw, and "
2814 "end bw (no exits in consensus, using mid)"),
2826 int num_present = 0, num_usable=0;
2827 time_t now = time(NULL);
2831 double paths, fraction;
2837 &num_present, &num_usable,
2843 return BOOTSTRAP_STATUS_LOADING_DESCRIPTORS + (int)
2844 (fraction*(BOOTSTRAP_STATUS_ENOUGH_DIRINFO-1 -
2845 BOOTSTRAP_STATUS_LOADING_DESCRIPTORS));
2854#define DFLT_PCT_USABLE_NEEDED 60
2859 DFLT_PCT_USABLE_NEEDED,
2870 time_t now = time(NULL);
2872 int num_present=0, num_usable=0;
2877 static int be_loud_when_things_work_again = 0;
2890 using_md = consensus->
flavor == FLAV_MICRODESC;
2894 char *status = NULL;
2896 &num_present, &num_usable,
2901 "We need more %sdescriptors: we have %d/%d, and "
2902 "can only build %d%% of likely paths. (We have %s.)",
2903 using_md?
"micro":
"", num_present, num_usable,
2904 (int)(paths*100), status);
2934 "We now have enough directory information to build circuits.");
2935 be_loud_when_things_work_again = 0;
2942 "Our directory information is no longer up-to-date "
2946 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.
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)
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)
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)
static bool nodes_have_common_family_id(const node_t *a, const node_t *b)
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)
static int use_family_lists
void nodelist_refresh_countries(void)
void router_dir_info_changed(void)
const smartlist_t * nodelist_get_list(void)
STATIC bool node_has_declared_family_list(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 void nodelist_update_consensus_params(const networkstatus_t *ns)
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)
STATIC int node_family_list_contains(const node_t *n1, const node_t *n2)
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)
static int use_family_ids
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)
STATIC void node_lookup_declared_family_list(smartlist_t *out, 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 smartlist_t * node_get_family_ids(const node_t *node)
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 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)
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.
int smartlist_contains_string(const smartlist_t *sl, const char *element)
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]
struct smartlist_t * family_ids
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
struct smartlist_t * family_ids
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