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;
147 static inline unsigned int
148 node_id_hash(
const node_t *node)
153 static inline unsigned int
160 HT_GENERATE2(nodelist_map,
node_t, ht_ent, node_id_hash, node_id_eq,
163 static inline unsigned int
164 node_ed_id_hash(
const node_t *node)
169 static inline unsigned int
177 HT_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
678 get_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
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) {
1349 return (
const uint8_t*)node->
identity;
1366 node_get_link_specifier_smartlist,(
const node_t *node,
bool direct_conn))
1368 link_specifier_t *ls;
1382 BUG(!tor_addr_port_is_valid_ap(&ap, 0))) {
1386 ls = link_specifier_new();
1387 link_specifier_set_ls_type(ls, LS_IPV4);
1389 link_specifier_set_un_ipv4_port(ls, ap.port);
1391 link_specifier_set_ls_len(ls,
sizeof(ap.addr.addr.in_addr) +
1396 ls = link_specifier_new();
1397 link_specifier_set_ls_type(ls, LS_LEGACY_ID);
1398 memcpy(link_specifier_getarray_un_legacy_id(ls), node->
identity,
1399 link_specifier_getlen_un_legacy_id(ls));
1400 link_specifier_set_ls_len(ls, link_specifier_getlen_un_legacy_id(ls));
1410 ls = link_specifier_new();
1411 link_specifier_set_ls_type(ls, LS_ED25519_ID);
1412 memcpy(link_specifier_getarray_un_ed25519_id(ls), &node->
ed25519_id,
1413 link_specifier_getlen_un_ed25519_id(ls));
1414 link_specifier_set_ls_len(ls, link_specifier_getlen_un_ed25519_id(ls));
1419 if (node_has_ipv6_orport(node)) {
1420 ls = link_specifier_new();
1422 link_specifier_set_ls_type(ls, LS_IPV6);
1423 size_t addr_len = link_specifier_getlen_un_ipv6_addr(ls);
1425 uint8_t *ipv6_array = link_specifier_getarray_un_ipv6_addr(ls);
1426 memcpy(ipv6_array,
in6_addr, addr_len);
1427 link_specifier_set_un_ipv6_port(ls, ap.port);
1429 link_specifier_set_ls_len(ls, addr_len +
sizeof(ap.port));
1438 link_specifier_smartlist_free_(
smartlist_t *ls_list)
1444 link_specifier_free(lspec));
1445 smartlist_free(ls_list);
1471 return rs->is_v2_dir;
1472 }
else if (node->ri) {
1490 (node->rs && node->md));
1501 int for_direct_connect)
1506 if ((is_bridge && for_direct_connect) || !we_use_mds) {
1512 if (node->rs == NULL || node->md == NULL)
1534 char *verbose_name_out)
1537 verbose_name_out[0] =
'$';
1554 char *verbose_name_out)
1558 verbose_name_out[0] =
'$';
1570 if (node && node->ri)
1598 if (family == AF_UNSPEC) {
1601 }
else if (family == AF_INET) {
1602 return node->ri != NULL;
1603 }
else if (family == AF_INET6) {
1616 #define SL_ADD_NEW_AP(r, addr_field, port_field, sl, valid) \
1618 if (tor_addr_port_is_valid(&(r)->addr_field, (r)->port_field, 0)) { \
1620 tor_addr_port_t *ap = tor_addr_port_new(&(r)->addr_field, \
1622 smartlist_add((sl), ap); \
1641 if (node->ri != NULL) {
1642 SL_ADD_NEW_AP(node->ri, ipv4_addr, ipv4_orport, sl, valid);
1646 if (!valid && node->rs != NULL) {
1647 SL_ADD_NEW_AP(node->rs, ipv4_addr, ipv4_orport, sl, valid);
1652 if (node->ri != NULL) {
1653 SL_ADD_NEW_AP(node->ri, ipv6_addr, ipv6_orport, sl, valid);
1656 if (!valid && node->rs != NULL) {
1657 SL_ADD_NEW_AP(node->rs, ipv6_addr, ipv6_orport, sl, valid);
1660 if (!valid && node->md != NULL) {
1661 SL_ADD_NEW_AP(node->md, ipv6_addr, ipv6_orport, sl, valid);
1667 #undef SL_ADD_NEW_AP
1687 if (node->ri && tor_addr_is_valid(&node->ri->
ipv4_addr, 0)) {
1689 }
else if (node->rs && tor_addr_is_valid(&node->rs->ipv4_addr, 0)) {
1690 return &node->rs->ipv4_addr;
1704 }
else if (len > 0) {
1744 node_has_ipv6_addr(
const node_t *node)
1750 if (node->ri && tor_addr_is_valid(&node->ri->
ipv6_addr, 0))
1752 if (node->rs && tor_addr_is_valid(&node->rs->
ipv6_addr, 0))
1754 if (node->md && tor_addr_is_valid(&node->md->
ipv6_addr, 0))
1762 node_has_ipv6_orport(
const node_t *node)
1766 return tor_addr_port_is_valid_ap(&ipv6_orport, 0);
1771 node_has_ipv6_dirport(
const node_t *node)
1775 return tor_addr_port_is_valid_ap(&ipv6_dirport, 0);
1795 node_assert_ok(node);
1804 !tor_addr_port_is_valid_ap(&ipv4_addr, 0)) {
1805 return node_has_ipv6_orport(node);
1810 #define RETURN_IPV4_AP(r, port_field, ap_out) \
1812 if (r && tor_addr_port_is_valid(&(r)->ipv4_addr, (r)->port_field, 0)) { \
1813 tor_addr_copy(&(ap_out)->addr, &(r)->ipv4_addr); \
1814 (ap_out)->port = (r)->port_field; \
1823 node_assert_ok(node);
1834 RETURN_IPV4_AP(node->ri, ipv4_orport, ap_out);
1835 RETURN_IPV4_AP(node->rs, ipv4_orport, ap_out);
1859 node_assert_ok(node);
1861 memset(ap_out, 0,
sizeof(*ap_out));
1869 if (node->ri && tor_addr_port_is_valid(&node->ri->
ipv6_addr,
1870 node->ri->ipv6_orport, 0)) {
1872 ap_out->port = node->ri->ipv6_orport;
1873 }
else if (node->rs && tor_addr_port_is_valid(&node->rs->
ipv6_addr,
1877 }
else if (node->md && tor_addr_port_is_valid(&node->md->
ipv6_addr,
1903 node_assert_ok(node);
1912 }
else if (!tor_addr_port_is_valid_ap(&ipv4_addr, 0)
1914 return node_has_ipv6_dirport(node);
1924 node_assert_ok(node);
1935 RETURN_IPV4_AP(node->ri, ipv4_dirport, ap_out);
1936 RETURN_IPV4_AP(node->rs, ipv4_dirport, ap_out);
1940 #undef RETURN_IPV4_AP
1962 node_assert_ok(node);
1972 if (node->ri && tor_addr_port_is_valid(&node->ri->
ipv6_addr,
1973 node->ri->ipv4_dirport, 0)) {
1975 ap_out->port = node->ri->ipv4_dirport;
1976 }
else if (node->rs && tor_addr_port_is_valid(&node->rs->
ipv6_addr,
2020 if (routerinfo_has_curve25519_onion_key(node->ri))
2033 node_get_rsa_onion_key(
const node_t *node)
2036 const char *onion_pkey;
2037 size_t onion_pkey_len;
2046 }
else if (node->rs && node->md) {
2053 pk = router_get_rsa_onion_pkey(onion_pkey, onion_pkey_len);
2068 ipv4_addr = &node->rs->ipv4_addr;
2074 if (BUG(!ipv4_addr)) {
2118 if (n && nickname[0]!=
'$' && !strcasecmp(n, nickname))
2143 }
else if (n1->md) {
2161 if (node->md && node->md->
family) {
2183 } SMARTLIST_FOREACH_END(
name);
2187 if (node->md && node->md->
family) {
2223 if (routerset_contains_node(rs, node1) &&
2224 routerset_contains_node(rs, node2))
2271 } SMARTLIST_FOREACH_END(node2);
2286 } SMARTLIST_FOREACH_END(node2);
2287 smartlist_free(declared_family);
2293 if (routerset_contains_node(rs, node)) {
2294 routerset_get_all_nodes(sl, rs, NULL, 0);
2336 int need_capacity,
int need_guard)
2340 if (need_capacity && !node->is_fast)
2364 } SMARTLIST_FOREACH_END(node);
2389 log_debug(
LD_DIR,
"Marking router %s as %s.",
2393 log_warn(
LD_NET,
"We just marked ourself as down. Are your external "
2394 "addresses reachable?");
2429 static int logged_delay=0;
2430 const char *delay_fetches_msg = NULL;
2433 log_notice(
LD_DIR,
"Delaying directory fetches: %s", delay_fetches_msg);
2504 routerset_t *in_set,
2507 const int md = (consensus->
flavor == FLAV_MICRODESC);
2508 *num_present = 0, *num_usable = 0;
2516 if ((exit_only & USABLE_DESCRIPTOR_EXIT_FLAG) && ! rs->is_exit)
2521 const char *
const digest = rs->descriptor_digest;
2531 if ((exit_only & USABLE_DESCRIPTOR_EXIT_POLICY) &&
2543 SMARTLIST_FOREACH_END(rs);
2545 log_debug(
LD_DIR,
"%d usable, %d present (%s%s%s%s%s).",
2546 *num_usable, *num_present,
2547 md ?
"microdesc" :
"desc",
2548 (exit_only & USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG) ?
2550 (exit_only & USABLE_DESCRIPTOR_EXIT_POLICY) ?
2552 (exit_only == USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG) ?
2554 (exit_only & USABLE_DESCRIPTOR_EXIT_FLAG) ?
2573 int *num_present_out,
int *num_usable_out,
2579 double f_guard, f_mid, f_exit;
2580 double f_path = 0.0;
2585 const int authdir = authdir_mode_v3(options);
2589 USABLE_DESCRIPTOR_ALL);
2591 "%s: %d present, %d usable",
2600 "%s: %d present, %d usable",
2617 smartlist_len(guards));
2622 NULL, USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG);
2624 "%s: %d present, %d usable",
2634 CONSENSUS_PATH_EXIT :
2635 CONSENSUS_PATH_INTERNAL);
2640 "The current consensus has no exit nodes. "
2641 "Tor can only build internal paths, "
2642 "such as paths to onion services.");
2648 }
else if (old_have_consensus_path == CONSENSUS_PATH_INTERNAL) {
2650 "The current consensus contains exit nodes. "
2651 "Tor can build exit and internal paths.");
2665 "f_guard: %.2f, f_mid: %.2f, f_exit: %.2f",
2670 smartlist_free(guards);
2671 smartlist_free(mid);
2672 smartlist_free(exits);
2675 double f_myexit, f_myexit_unflagged;
2682 USABLE_DESCRIPTOR_EXIT_POLICY_AND_FLAG);
2684 "%s: %d present, %d usable",
2694 USABLE_DESCRIPTOR_EXIT_POLICY);
2696 "%s: %d present, %d usable",
2697 "myexits_unflagged (initial)",
2704 WEIGHT_FOR_EXIT, 0);
2707 "f_exit: %.2f, f_myexit: %.2f, f_myexit_unflagged: %.2f",
2710 f_myexit_unflagged);
2715 if (smartlist_len(myexits) == 0 &&
2716 smartlist_len(myexits_unflagged)) {
2717 f_myexit = f_myexit_unflagged;
2720 smartlist_free(myexits);
2721 smartlist_free(myexits_unflagged);
2727 if (f_myexit < f_exit)
2742 if (f_exit <= 0.0) {
2747 f_path = f_guard * f_mid * f_exit;
2751 "%d%% of guards bw, "
2752 "%d%% of midpoint bw, and "
2760 "end bw (no exits in consensus, using mid)"),
2772 int num_present = 0, num_usable=0;
2773 time_t now = time(NULL);
2777 double paths, fraction;
2783 &num_present, &num_usable,
2789 return BOOTSTRAP_STATUS_LOADING_DESCRIPTORS + (int)
2790 (fraction*(BOOTSTRAP_STATUS_ENOUGH_DIRINFO-1 -
2791 BOOTSTRAP_STATUS_LOADING_DESCRIPTORS));
2800 #define DFLT_PCT_USABLE_NEEDED 60
2805 DFLT_PCT_USABLE_NEEDED,
2816 time_t now = time(NULL);
2818 int num_present=0, num_usable=0;
2835 using_md = consensus->
flavor == FLAV_MICRODESC;
2839 char *status = NULL;
2841 &num_present, &num_usable,
2846 "We need more %sdescriptors: we have %d/%d, and "
2847 "can only build %d%% of likely paths. (We have %s.)",
2848 using_md?
"micro":
"", num_present, num_usable,
2849 (
int)(paths*100), status);
2879 "We now have enough directory information to build circuits.");
2886 "Our directory information is no longer up-to-date "
void tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
const char * tor_addr_to_str(char *dest, const tor_addr_t *addr, size_t len, int decorate)
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)
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)
address_set_t * address_set_new(int max_addresses_guess)
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)
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.
char * entry_guards_get_err_str_if_dir_info_missing(int using_mds, int num_present, int num_usable)
int num_bridges_usable(int use_maybe_reachable)
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)
uint64_t hs_get_next_time_period_num(time_t now)
uint64_t hs_get_previous_time_period_num(time_t now)
uint8_t * hs_get_current_srv(uint64_t time_period_num, const networkstatus_t *ns)
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)
uint8_t * hs_get_previous_srv(uint64_t time_period_num, const networkstatus_t *ns)
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_free_(void *mem)
void * tor_reallocarray_(void *ptr, size_t sz1, size_t sz2)
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)
int client_would_use_router(const routerstatus_t *rs, time_t now)
networkstatus_t * networkstatus_get_reasonably_live_consensus(time_t now, int flavor)
networkstatus_t * networkstatus_get_latest_consensus(void)
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)
const routerstatus_t * router_get_consensus_status_by_descriptor_digest(networkstatus_t *consensus, const char *digest)
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)
static int node_add_to_ed25519_map(node_t *node)
const node_t * node_get_by_ed25519_id(const ed25519_public_key_t *ed_id)
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)
node_t * node_get_mutable_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]
const char * node_get_platform(const node_t *node)
void nodelist_free_all(void)
void nodelist_add_node_and_family(smartlist_t *sl, const node_t *node)
static const protover_summary_flags_t * node_get_protover_summary_flags(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)
int node_is_good_exit(const node_t *node)
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 smartlist_t * nodelist_get_list(void)
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)
smartlist_t * node_get_all_orports(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)
smartlist_t * nodelist_find_nodes_with_microdesc(const microdesc_t *md)
int node_is_me(const node_t *node)
const char * node_get_nickname(const node_t *node)
static const protover_summary_flags_t zero_protover_flags
int node_has_any_descriptor(const node_t *node)
void nodelist_purge(void)
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)
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 node_t * node_get_by_nickname(const char *nickname, unsigned flags)
node_t * nodelist_set_routerinfo(routerinfo_t *ri, routerinfo_t **ri_old_out)
static void node_addrs_changed(node_t *node)
node_t * node_get_mutable_by_ed25519_id(const ed25519_public_key_t *ed_id)
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 node_t * node_get_or_create(const char *identity_digest)
const node_t * router_find_exact_exit_enclave(const char *address, uint16_t port)
int node_allows_single_hop_exits(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 node_t * node_get_by_hex_id(const char *hex_id, unsigned flags)
void nodelist_set_consensus(const networkstatus_t *ns)
bool nodelist_reentry_contains(const tor_addr_t *addr, uint16_t port)
static const tor_addr_t * node_get_prim_addr_ipv4(const node_t *node)
void nodelist_remove_microdesc(const char *identity_digest, microdesc_t *md)
const node_t * node_get_by_id(const char *identity_digest)
void node_set_country(node_t *node)
const uint8_t * node_get_rsa_id_digest(const 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)
const ed25519_public_key_t * node_get_ed25519_id(const node_t *node)
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)
const char * get_dir_info_status_string(void)
node_t * nodelist_add_microdesc(microdesc_t *md)
static char * build_addr_port_item(const tor_addr_t *addr, const uint16_t port)
const curve25519_public_key_t * node_get_curve25519_onion_key(const node_t *node)
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)
int hex_digest_nickname_decode(const char *hexdigest, char *digest_out, char *nickname_qualifier_char_out, char *nickname_out)
routerlist_t * router_get_routerlist(void)
int routers_have_same_or_addrs(const routerinfo_t *r1, const routerinfo_t *r2)
signed_descriptor_t * router_get_by_descriptor_digest(const char *digest)
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_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