diff options
Diffstat (limited to 'src/feature/nodelist/routerlist.h')
-rw-r--r-- | src/feature/nodelist/routerlist.h | 154 |
1 files changed, 7 insertions, 147 deletions
diff --git a/src/feature/nodelist/routerlist.h b/src/feature/nodelist/routerlist.h index 4b7406364f..c3e97d9dd2 100644 --- a/src/feature/nodelist/routerlist.h +++ b/src/feature/nodelist/routerlist.h @@ -42,108 +42,13 @@ typedef enum was_router_added_t { ROUTER_CERTS_EXPIRED = -8 } was_router_added_t; -/** Flags to be passed to control router_choose_random_node() to indicate what - * kind of nodes to pick according to what algorithm. */ -typedef enum router_crn_flags_t { - CRN_NEED_UPTIME = 1<<0, - CRN_NEED_CAPACITY = 1<<1, - CRN_NEED_GUARD = 1<<2, - /* XXXX not used, apparently. */ - CRN_WEIGHT_AS_EXIT = 1<<5, - CRN_NEED_DESC = 1<<6, - /* On clients, only provide nodes that satisfy ClientPreferIPv6OR */ - CRN_PREF_ADDR = 1<<7, - /* On clients, only provide nodes that we can connect to directly, based on - * our firewall rules */ - CRN_DIRECT_CONN = 1<<8, - /* On clients, only provide nodes with HSRend >= 2 protocol version which - * is required for hidden service version >= 3. */ - CRN_RENDEZVOUS_V3 = 1<<9, -} router_crn_flags_t; +/** How long do we avoid using a directory server after it's given us a 503? */ +#define DIR_503_TIMEOUT (60*60) -/** Possible ways to weight routers when choosing one randomly. See - * routerlist_sl_choose_by_bandwidth() for more information.*/ -typedef enum bandwidth_weight_rule_t { - NO_WEIGHTING, WEIGHT_FOR_EXIT, WEIGHT_FOR_MID, WEIGHT_FOR_GUARD, - WEIGHT_FOR_DIR -} bandwidth_weight_rule_t; - -/* Flags for pick_directory_server() and pick_trusteddirserver(). */ -/** Flag to indicate that we should not automatically be willing to use - * ourself to answer a directory request. - * Passed to router_pick_directory_server (et al).*/ -#define PDS_ALLOW_SELF (1<<0) -/** Flag to indicate that if no servers seem to be up, we should mark all - * directory servers as up and try again. - * Passed to router_pick_directory_server (et al).*/ -#define PDS_RETRY_IF_NO_SERVERS (1<<1) -/** Flag to indicate that we should not exclude directory servers that - * our ReachableAddress settings would exclude. This usually means that - * we're going to connect to the server over Tor, and so we don't need to - * worry about our firewall telling us we can't. - * Passed to router_pick_directory_server (et al).*/ -#define PDS_IGNORE_FASCISTFIREWALL (1<<2) -/** Flag to indicate that we should not use any directory authority to which - * we have an existing directory connection for downloading server descriptors - * or extrainfo documents. - * - * Passed to router_pick_directory_server (et al) - */ -#define PDS_NO_EXISTING_SERVERDESC_FETCH (1<<3) -/** Flag to indicate that we should not use any directory authority to which - * we have an existing directory connection for downloading microdescs. - * - * Passed to router_pick_directory_server (et al) - */ -#define PDS_NO_EXISTING_MICRODESC_FETCH (1<<4) - -int get_n_authorities(dirinfo_type_t type); -int trusted_dirs_reload_certs(void); - -/* - * Pass one of these as source to trusted_dirs_load_certs_from_string() - * to indicate whence string originates; this controls error handling - * behavior such as marking downloads as failed. - */ - -#define TRUSTED_DIRS_CERTS_SRC_SELF 0 -#define TRUSTED_DIRS_CERTS_SRC_FROM_STORE 1 -#define TRUSTED_DIRS_CERTS_SRC_DL_BY_ID_DIGEST 2 -#define TRUSTED_DIRS_CERTS_SRC_DL_BY_ID_SK_DIGEST 3 -#define TRUSTED_DIRS_CERTS_SRC_FROM_VOTE 4 - -int trusted_dirs_load_certs_from_string(const char *contents, int source, - int flush, const char *source_dir); -void trusted_dirs_flush_certs_to_disk(void); -authority_cert_t *authority_cert_get_newest_by_id(const char *id_digest); -authority_cert_t *authority_cert_get_by_sk_digest(const char *sk_digest); -authority_cert_t *authority_cert_get_by_digests(const char *id_digest, - const char *sk_digest); -void authority_cert_get_all(smartlist_t *certs_out); -void authority_cert_dl_failed(const char *id_digest, - const char *signing_key_digest, int status); -void authority_certs_fetch_missing(networkstatus_t *status, time_t now, - const char *dir_hint); int router_reload_router_list(void); -int authority_cert_dl_looks_uncertain(const char *id_digest); -const smartlist_t *router_get_trusted_dir_servers(void); -const smartlist_t *router_get_fallback_dir_servers(void); -int authority_cert_is_blacklisted(const authority_cert_t *cert); -const routerstatus_t *router_pick_directory_server(dirinfo_type_t type, - int flags); -dir_server_t *router_get_trusteddirserver_by_digest(const char *d); -dir_server_t *router_get_fallback_dirserver_by_digest( - const char *digest); -int router_digest_is_fallback_dir(const char *digest); -MOCK_DECL(dir_server_t *, trusteddirserver_get_by_v3_auth_digest, - (const char *d)); -const routerstatus_t *router_pick_trusteddirserver(dirinfo_type_t type, - int flags); -const routerstatus_t *router_pick_fallback_dirserver(dirinfo_type_t type, - int flags); int router_skip_or_reachability(const or_options_t *options, int try_ip_pref); -int router_get_my_share_of_directory_requests(double *v3_share_out); +int router_skip_dir_reachability(const or_options_t *options, int try_ip_pref); void router_reset_status_download_failures(void); int routers_have_same_or_addrs(const routerinfo_t *r1, const routerinfo_t *r2); void router_add_running_nodes_to_smartlist(smartlist_t *sl, int need_uptime, @@ -155,21 +60,6 @@ const routerinfo_t *routerlist_find_my_routerinfo(void); uint32_t router_get_advertised_bandwidth(const routerinfo_t *router); uint32_t router_get_advertised_bandwidth_capped(const routerinfo_t *router); -const node_t *node_sl_choose_by_bandwidth(const smartlist_t *sl, - bandwidth_weight_rule_t rule); -double frac_nodes_with_descriptors(const smartlist_t *sl, - bandwidth_weight_rule_t rule, - int for_direct_conn); - -const node_t *router_choose_random_node(smartlist_t *excludedsmartlist, - struct routerset_t *excludedset, - router_crn_flags_t flags); - -int router_digest_is_trusted_dir_type(const char *digest, - dirinfo_type_t type); -#define router_digest_is_trusted_dir(d) \ - router_digest_is_trusted_dir_type((d), NO_DIRINFO) - int hexdigest_to_digest(const char *hexdigest, char *digest); const routerinfo_t *router_get_by_id_digest(const char *digest); routerinfo_t *router_get_mutable_by_digest(const char *digest); @@ -194,13 +84,10 @@ void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old, void routerlist_free_all(void); void routerlist_reset_warnings(void); -MOCK_DECL(smartlist_t *, list_authority_ids_with_downloads, (void)); -MOCK_DECL(download_status_t *, id_only_download_status_for_authority_id, - (const char *digest)); -MOCK_DECL(smartlist_t *, list_sk_digests_for_authority_id, - (const char *digest)); -MOCK_DECL(download_status_t *, download_status_for_authority_id_and_sk, - (const char *id_digest, const char *sk_digest)); +/* XXXX move this */ +void list_pending_downloads(digestmap_t *result, + digest256map_t *result256, + int purpose, const char *prefix); static int WRA_WAS_ADDED(was_router_added_t s); static int WRA_WAS_OUTDATED(was_router_added_t s); @@ -269,21 +156,6 @@ void routerlist_retry_directory_downloads(time_t now); int router_exit_policy_rejects_all(const routerinfo_t *router); -dir_server_t *trusted_dir_server_new(const char *nickname, const char *address, - uint16_t dir_port, uint16_t or_port, - const tor_addr_port_t *addrport_ipv6, - const char *digest, const char *v3_auth_digest, - dirinfo_type_t type, double weight); -dir_server_t *fallback_dir_server_new(const tor_addr_t *addr, - uint16_t dir_port, uint16_t or_port, - const tor_addr_port_t *addrport_ipv6, - const char *id_digest, double weight); -void dir_server_add(dir_server_t *ent); - -void authority_cert_free_(authority_cert_t *cert); -#define authority_cert_free(cert) \ - FREE_AND_NULL(authority_cert_t, authority_cert_free_, (cert)) -void clear_dir_servers(void); void update_consensus_router_descriptor_downloads(time_t now, int is_vote, networkstatus_t *consensus); void update_router_descriptor_downloads(time_t now); @@ -321,16 +193,6 @@ int hex_digest_nickname_matches(const char *hexdigest, const char *nickname); #ifdef ROUTERLIST_PRIVATE -STATIC int choose_array_element_by_weight(const uint64_t *entries, - int n_entries); -STATIC void scale_array_elements_to_u64(uint64_t *entries_out, - const double *entries_in, - int n_entries, - uint64_t *total_out); -STATIC const routerstatus_t *router_pick_directory_server_impl( - dirinfo_type_t auth, int flags, - int *n_busy_out); - MOCK_DECL(int, router_descriptor_is_older_than, (const routerinfo_t *router, int seconds)); MOCK_DECL(STATIC was_router_added_t, extrainfo_insert, @@ -339,8 +201,6 @@ MOCK_DECL(STATIC was_router_added_t, extrainfo_insert, MOCK_DECL(STATIC void, initiate_descriptor_downloads, (const routerstatus_t *source, int purpose, smartlist_t *digests, int lo, int hi, int pds_flags)); -STATIC int router_is_already_dir_fetching(const tor_addr_port_t *ap, - int serverdesc, int microdesc); #endif /* defined(ROUTERLIST_PRIVATE) */ |