2010-07-21 17:08:11 +02:00
|
|
|
/* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2016-02-27 18:48:19 +01:00
|
|
|
* Copyright (c) 2007-2016, The Tor Project, Inc. */
|
2010-07-21 17:08:11 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file routerlist.h
|
2010-07-28 17:42:33 +02:00
|
|
|
* \brief Header file for routerlist.c.
|
2010-07-21 17:08:11 +02:00
|
|
|
**/
|
|
|
|
|
2012-10-12 18:13:10 +02:00
|
|
|
#ifndef TOR_ROUTERLIST_H
|
|
|
|
#define TOR_ROUTERLIST_H
|
2010-07-21 17:08:11 +02:00
|
|
|
|
2013-06-06 23:58:28 +02:00
|
|
|
#include "testsupport.h"
|
|
|
|
|
2010-11-08 20:27:36 +01:00
|
|
|
int get_n_authorities(dirinfo_type_t type);
|
2010-07-21 17:08:11 +02:00
|
|
|
int trusted_dirs_reload_certs(void);
|
2013-05-09 13:56:54 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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,
|
2016-05-04 08:47:28 +02:00
|
|
|
int flush, const char *source_dir);
|
2010-07-21 17:08:11 +02:00
|
|
|
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);
|
2013-05-09 13:56:54 +02:00
|
|
|
void authority_cert_dl_failed(const char *id_digest,
|
|
|
|
const char *signing_key_digest, int status);
|
2016-05-04 08:38:27 +02:00
|
|
|
void authority_certs_fetch_missing(networkstatus_t *status, time_t now,
|
|
|
|
const char *dir_hint);
|
2010-07-21 17:08:11 +02:00
|
|
|
int router_reload_router_list(void);
|
2010-09-02 22:42:18 +02:00
|
|
|
int authority_cert_dl_looks_uncertain(const char *id_digest);
|
2012-09-08 04:55:53 +02:00
|
|
|
const smartlist_t *router_get_trusted_dir_servers(void);
|
2012-09-10 21:23:39 +02:00
|
|
|
const smartlist_t *router_get_fallback_dir_servers(void);
|
2014-04-11 16:22:14 +02:00
|
|
|
int authority_cert_is_blacklisted(const authority_cert_t *cert);
|
2010-07-21 17:08:11 +02:00
|
|
|
|
2010-11-08 20:27:36 +01:00
|
|
|
const routerstatus_t *router_pick_directory_server(dirinfo_type_t type,
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
int flags);
|
2012-09-10 21:55:27 +02:00
|
|
|
dir_server_t *router_get_trusteddirserver_by_digest(const char *d);
|
|
|
|
dir_server_t *router_get_fallback_dirserver_by_digest(
|
2012-09-10 21:23:39 +02:00
|
|
|
const char *digest);
|
2015-12-10 19:49:23 +01:00
|
|
|
int router_digest_is_fallback_dir(const char *digest);
|
2016-05-12 19:30:07 +02:00
|
|
|
MOCK_DECL(dir_server_t *, trusteddirserver_get_by_v3_auth_digest,
|
|
|
|
(const char *d));
|
2010-11-08 20:27:36 +01:00
|
|
|
const routerstatus_t *router_pick_trusteddirserver(dirinfo_type_t type,
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
int flags);
|
2012-09-10 21:23:39 +02:00
|
|
|
const routerstatus_t *router_pick_fallback_dirserver(dirinfo_type_t type,
|
|
|
|
int flags);
|
2016-07-07 08:10:56 +02:00
|
|
|
int router_skip_or_reachability(const or_options_t *options, int try_ip_pref);
|
2014-01-29 21:17:05 +01:00
|
|
|
int router_get_my_share_of_directory_requests(double *v3_share_out);
|
2010-07-21 17:08:11 +02:00
|
|
|
void router_reset_status_download_failures(void);
|
2012-05-11 10:22:45 +02:00
|
|
|
int routers_have_same_or_addrs(const routerinfo_t *r1, const routerinfo_t *r2);
|
2014-09-15 14:28:11 +02:00
|
|
|
void router_add_running_nodes_to_smartlist(smartlist_t *sl, int allow_invalid,
|
|
|
|
int need_uptime, int need_capacity,
|
2015-12-18 01:28:54 +01:00
|
|
|
int need_guard, int need_desc,
|
2016-08-18 04:02:33 +02:00
|
|
|
int pref_addr, int direct_conn);
|
2014-09-15 14:28:11 +02:00
|
|
|
|
2010-09-29 06:38:32 +02:00
|
|
|
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);
|
2010-07-21 17:08:11 +02:00
|
|
|
|
2013-01-18 18:56:47 +01:00
|
|
|
const node_t *node_sl_choose_by_bandwidth(const smartlist_t *sl,
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
bandwidth_weight_rule_t rule);
|
2013-01-18 18:56:47 +01:00
|
|
|
double frac_nodes_with_descriptors(const smartlist_t *sl,
|
|
|
|
bandwidth_weight_rule_t rule);
|
2010-07-21 17:08:11 +02:00
|
|
|
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
const node_t *router_choose_random_node(smartlist_t *excludedsmartlist,
|
2010-07-21 17:08:11 +02:00
|
|
|
struct routerset_t *excludedset,
|
|
|
|
router_crn_flags_t flags);
|
|
|
|
|
2011-05-30 21:41:46 +02:00
|
|
|
int router_is_named(const routerinfo_t *router);
|
2010-07-21 17:08:11 +02:00
|
|
|
int router_digest_is_trusted_dir_type(const char *digest,
|
2010-11-08 20:27:36 +01:00
|
|
|
dirinfo_type_t type);
|
2010-07-21 17:08:11 +02:00
|
|
|
#define router_digest_is_trusted_dir(d) \
|
2010-11-08 20:35:02 +01:00
|
|
|
router_digest_is_trusted_dir_type((d), NO_DIRINFO)
|
2010-07-21 17:08:11 +02:00
|
|
|
|
|
|
|
int router_addr_is_trusted_dir(uint32_t addr);
|
|
|
|
int hexdigest_to_digest(const char *hexdigest, char *digest);
|
2010-10-14 17:49:51 +02:00
|
|
|
const routerinfo_t *router_get_by_id_digest(const char *digest);
|
2010-09-29 06:38:32 +02:00
|
|
|
routerinfo_t *router_get_mutable_by_digest(const char *digest);
|
2010-07-21 17:08:11 +02:00
|
|
|
signed_descriptor_t *router_get_by_descriptor_digest(const char *digest);
|
2014-10-07 15:20:44 +02:00
|
|
|
MOCK_DECL(signed_descriptor_t *,router_get_by_extrainfo_digest,
|
|
|
|
(const char *digest));
|
2010-07-21 17:08:11 +02:00
|
|
|
signed_descriptor_t *extrainfo_get_by_descriptor_digest(const char *digest);
|
2010-09-29 06:38:32 +02:00
|
|
|
const char *signed_descriptor_get_body(const signed_descriptor_t *desc);
|
|
|
|
const char *signed_descriptor_get_annotations(const signed_descriptor_t *desc);
|
2010-07-21 17:08:11 +02:00
|
|
|
routerlist_t *router_get_routerlist(void);
|
|
|
|
void routerinfo_free(routerinfo_t *router);
|
|
|
|
void extrainfo_free(extrainfo_t *extrainfo);
|
|
|
|
void routerlist_free(routerlist_t *rl);
|
|
|
|
void dump_routerlist_mem_usage(int severity);
|
|
|
|
void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old,
|
|
|
|
time_t now);
|
|
|
|
void routerlist_free_all(void);
|
|
|
|
void routerlist_reset_warnings(void);
|
|
|
|
|
2016-06-30 20:19:55 +02:00
|
|
|
MOCK_DECL(smartlist_t *, list_authority_ids_with_downloads, (void));
|
2016-06-28 23:30:57 +02:00
|
|
|
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));
|
2016-06-28 02:09:45 +02:00
|
|
|
|
2010-07-21 17:08:11 +02:00
|
|
|
static int WRA_WAS_ADDED(was_router_added_t s);
|
|
|
|
static int WRA_WAS_OUTDATED(was_router_added_t s);
|
|
|
|
static int WRA_WAS_REJECTED(was_router_added_t s);
|
2014-10-13 20:11:27 +02:00
|
|
|
static int WRA_NEVER_DOWNLOADABLE(was_router_added_t s);
|
2012-06-05 06:17:54 +02:00
|
|
|
/** Return true iff the outcome code in <b>s</b> indicates that the descriptor
|
|
|
|
* was added. It might still be necessary to check whether the descriptor
|
|
|
|
* generator should be notified.
|
2010-07-21 17:08:11 +02:00
|
|
|
*/
|
2015-12-10 16:19:43 +01:00
|
|
|
static inline int
|
2010-07-21 17:08:11 +02:00
|
|
|
WRA_WAS_ADDED(was_router_added_t s) {
|
|
|
|
return s == ROUTER_ADDED_SUCCESSFULLY || s == ROUTER_ADDED_NOTIFY_GENERATOR;
|
|
|
|
}
|
2012-06-05 06:17:54 +02:00
|
|
|
/** Return true iff the outcome code in <b>s</b> indicates that the descriptor
|
|
|
|
* was not added because it was either:
|
2010-07-21 17:08:11 +02:00
|
|
|
* - not in the consensus
|
|
|
|
* - neither in the consensus nor in any networkstatus document
|
|
|
|
* - it was outdated.
|
2014-10-01 17:54:07 +02:00
|
|
|
* - its certificates were expired.
|
2010-07-21 17:08:11 +02:00
|
|
|
*/
|
2015-12-10 16:19:43 +01:00
|
|
|
static inline int WRA_WAS_OUTDATED(was_router_added_t s)
|
2010-07-21 17:08:11 +02:00
|
|
|
{
|
2014-10-13 20:11:27 +02:00
|
|
|
return (s == ROUTER_WAS_TOO_OLD ||
|
2014-11-11 19:56:40 +01:00
|
|
|
s == ROUTER_IS_ALREADY_KNOWN ||
|
2010-07-21 17:08:11 +02:00
|
|
|
s == ROUTER_NOT_IN_CONSENSUS ||
|
2014-10-01 17:54:07 +02:00
|
|
|
s == ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS ||
|
|
|
|
s == ROUTER_CERTS_EXPIRED);
|
2010-07-21 17:08:11 +02:00
|
|
|
}
|
2012-06-05 06:17:54 +02:00
|
|
|
/** Return true iff the outcome code in <b>s</b> indicates that the descriptor
|
|
|
|
* was flat-out rejected. */
|
2015-12-10 16:19:43 +01:00
|
|
|
static inline int WRA_WAS_REJECTED(was_router_added_t s)
|
2010-07-21 17:08:11 +02:00
|
|
|
{
|
|
|
|
return (s == ROUTER_AUTHDIR_REJECTS);
|
|
|
|
}
|
2014-10-13 20:11:27 +02:00
|
|
|
/** Return true iff the outcome code in <b>s</b> indicates that the descriptor
|
|
|
|
* was flat-out rejected. */
|
2015-12-10 16:19:43 +01:00
|
|
|
static inline int WRA_NEVER_DOWNLOADABLE(was_router_added_t s)
|
2014-10-13 20:11:27 +02:00
|
|
|
{
|
|
|
|
return (s == ROUTER_AUTHDIR_REJECTS ||
|
|
|
|
s == ROUTER_BAD_EI ||
|
2014-10-01 17:54:07 +02:00
|
|
|
s == ROUTER_WAS_TOO_OLD ||
|
|
|
|
s == ROUTER_CERTS_EXPIRED);
|
2014-10-13 20:11:27 +02:00
|
|
|
}
|
2010-07-21 17:08:11 +02:00
|
|
|
was_router_added_t router_add_to_routerlist(routerinfo_t *router,
|
|
|
|
const char **msg,
|
|
|
|
int from_cache,
|
|
|
|
int from_fetch);
|
|
|
|
was_router_added_t router_add_extrainfo_to_routerlist(
|
|
|
|
extrainfo_t *ei, const char **msg,
|
|
|
|
int from_cache, int from_fetch);
|
2010-08-18 19:36:09 +02:00
|
|
|
void routerlist_descriptors_added(smartlist_t *sl, int from_cache);
|
2010-07-21 17:08:11 +02:00
|
|
|
void routerlist_remove_old_routers(void);
|
|
|
|
int router_load_single_router(const char *s, uint8_t purpose, int cache,
|
|
|
|
const char **msg);
|
|
|
|
int router_load_routers_from_string(const char *s, const char *eos,
|
|
|
|
saved_location_t saved_location,
|
|
|
|
smartlist_t *requested_fingerprints,
|
|
|
|
int descriptor_digests,
|
|
|
|
const char *prepend_annotations);
|
|
|
|
void router_load_extrainfo_from_string(const char *s, const char *eos,
|
|
|
|
saved_location_t saved_location,
|
|
|
|
smartlist_t *requested_fingerprints,
|
|
|
|
int descriptor_digests);
|
|
|
|
|
|
|
|
void routerlist_retry_directory_downloads(time_t now);
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
|
2010-09-29 06:38:32 +02:00
|
|
|
int router_exit_policy_rejects_all(const routerinfo_t *router);
|
2012-09-10 22:33:19 +02:00
|
|
|
|
|
|
|
dir_server_t *trusted_dir_server_new(const char *nickname, const char *address,
|
|
|
|
uint16_t dir_port, uint16_t or_port,
|
2013-02-22 22:10:40 +01:00
|
|
|
const tor_addr_port_t *addrport_ipv6,
|
2012-09-10 22:33:19 +02:00
|
|
|
const char *digest, const char *v3_auth_digest,
|
2012-09-11 00:13:28 +02:00
|
|
|
dirinfo_type_t type, double weight);
|
2012-09-10 22:33:19 +02:00
|
|
|
dir_server_t *fallback_dir_server_new(const tor_addr_t *addr,
|
|
|
|
uint16_t dir_port, uint16_t or_port,
|
2013-02-22 22:10:40 +01:00
|
|
|
const tor_addr_port_t *addrport_ipv6,
|
2012-09-11 00:13:28 +02:00
|
|
|
const char *id_digest, double weight);
|
2012-09-10 22:33:19 +02:00
|
|
|
void dir_server_add(dir_server_t *ent);
|
|
|
|
|
2010-07-21 17:08:11 +02:00
|
|
|
void authority_cert_free(authority_cert_t *cert);
|
2012-09-10 21:23:39 +02:00
|
|
|
void clear_dir_servers(void);
|
2010-07-21 17:08:11 +02:00
|
|
|
void update_consensus_router_descriptor_downloads(time_t now, int is_vote,
|
|
|
|
networkstatus_t *consensus);
|
|
|
|
void update_router_descriptor_downloads(time_t now);
|
2010-11-12 18:05:27 +01:00
|
|
|
void update_all_descriptor_downloads(time_t now);
|
2010-07-21 17:08:11 +02:00
|
|
|
void update_extrainfo_downloads(time_t now);
|
|
|
|
void router_reset_descriptor_download_failures(void);
|
2010-09-29 06:38:32 +02:00
|
|
|
int router_differences_are_cosmetic(const routerinfo_t *r1,
|
|
|
|
const routerinfo_t *r2);
|
2016-05-17 19:24:01 +02:00
|
|
|
int routerinfo_incompatible_with_extrainfo(const crypto_pk_t *ri,
|
2010-09-29 06:38:32 +02:00
|
|
|
extrainfo_t *ei,
|
2010-07-21 17:08:11 +02:00
|
|
|
signed_descriptor_t *sd,
|
|
|
|
const char **msg);
|
2016-07-07 04:58:47 +02:00
|
|
|
int routerinfo_has_curve25519_onion_key(const routerinfo_t *ri);
|
|
|
|
int routerstatus_version_supports_ntor(const routerstatus_t *rs,
|
|
|
|
int allow_unknown_versions);
|
2010-07-21 17:08:11 +02:00
|
|
|
|
2010-09-29 06:38:32 +02:00
|
|
|
void routerlist_assert_ok(const routerlist_t *rl);
|
|
|
|
const char *esc_router_info(const routerinfo_t *router);
|
2010-07-21 17:08:11 +02:00
|
|
|
void routers_sort_by_identity(smartlist_t *routers);
|
|
|
|
|
|
|
|
void refresh_all_country_info(void);
|
|
|
|
|
2014-10-31 16:32:32 +01:00
|
|
|
void list_pending_microdesc_downloads(digest256map_t *result);
|
2010-05-11 23:20:33 +02:00
|
|
|
void launch_descriptor_downloads(int purpose,
|
|
|
|
smartlist_t *downloadable,
|
2010-09-29 07:35:08 +02:00
|
|
|
const routerstatus_t *source,
|
2010-05-11 23:20:33 +02:00
|
|
|
time_t now);
|
|
|
|
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
int hex_digest_nickname_decode(const char *hexdigest,
|
|
|
|
char *digest_out,
|
|
|
|
char *nickname_qualifier_out,
|
|
|
|
char *nickname_out);
|
2012-09-13 18:57:46 +02:00
|
|
|
int hex_digest_nickname_matches(const char *hexdigest,
|
|
|
|
const char *identity_digest,
|
|
|
|
const char *nickname, int is_named);
|
Initial conversion to use node_t throughout our codebase.
A node_t is an abstraction over routerstatus_t, routerinfo_t, and
microdesc_t. It should try to present a consistent interface to all
of them. There should be a node_t for a server whenever there is
* A routerinfo_t for it in the routerlist
* A routerstatus_t in the current_consensus.
(note that a microdesc_t alone isn't enough to make a node_t exist,
since microdescriptors aren't usable on their own.)
There are three ways to get a node_t right now: looking it up by ID,
looking it up by nickname, and iterating over the whole list of
microdescriptors.
All (or nearly all) functions that are supposed to return "a router"
-- especially those used in building connections and circuits --
should return a node_t, not a routerinfo_t or a routerstatus_t.
A node_t should hold all the *mutable* flags about a node. This
patch moves the is_foo flags from routerinfo_t into node_t. The
flags in routerstatus_t remain, but they get set from the consensus
and should not change.
Some other highlights of this patch are:
* Looking up routerinfo and routerstatus by nickname is now
unified and based on the "look up a node by nickname" function.
This tries to look only at the values from current consensus,
and not get confused by the routerinfo_t->is_named flag, which
could get set for other weird reasons. This changes the
behavior of how authorities (when acting as clients) deal with
nodes that have been listed by nickname.
* I tried not to artificially increase the size of the diff here
by moving functions around. As a result, some functions that
now operate on nodes are now in the wrong file -- they should
get moved to nodelist.c once this refactoring settles down.
This moving should happen as part of a patch that moves
functions AND NOTHING ELSE.
* Some old code is now left around inside #if 0/1 blocks, and
should get removed once I've verified that I don't want it
sitting around to see how we used to do things.
There are still some unimplemented functions: these are flagged
with "UNIMPLEMENTED_NODELIST()." I'll work on filling in the
implementation here, piece by piece.
I wish this patch could have been smaller, but there did not seem to
be any piece of it that was independent from the rest. Moving flags
forces many functions that once returned routerinfo_t * to return
node_t *, which forces their friends to change, and so on.
2010-09-29 21:00:41 +02:00
|
|
|
|
2012-08-09 19:47:42 +02:00
|
|
|
#ifdef ROUTERLIST_PRIVATE
|
2016-04-27 16:16:43 +02:00
|
|
|
STATIC int choose_array_element_by_weight(const uint64_t *entries,
|
2013-06-06 23:58:28 +02:00
|
|
|
int n_entries);
|
2016-04-27 16:16:43 +02:00
|
|
|
STATIC void scale_array_elements_to_u64(uint64_t *entries_out,
|
2016-06-09 13:50:25 +02:00
|
|
|
const double *entries_in,
|
|
|
|
int n_entries,
|
2013-06-06 23:58:28 +02:00
|
|
|
uint64_t *total_out);
|
2015-01-26 20:49:48 +01:00
|
|
|
STATIC const routerstatus_t *router_pick_directory_server_impl(
|
|
|
|
dirinfo_type_t auth, int flags,
|
|
|
|
int *n_busy_out);
|
2014-06-24 20:12:51 +02:00
|
|
|
|
2014-07-09 18:20:41 +02:00
|
|
|
MOCK_DECL(int, router_descriptor_is_older_than, (const routerinfo_t *router,
|
|
|
|
int seconds));
|
2014-10-13 20:11:27 +02:00
|
|
|
MOCK_DECL(STATIC was_router_added_t, extrainfo_insert,
|
2015-01-07 19:11:06 +01:00
|
|
|
(routerlist_t *rl, extrainfo_t *ei, int warn_if_incompatible));
|
2014-10-07 15:20:44 +02:00
|
|
|
|
2014-09-23 18:21:08 +02:00
|
|
|
MOCK_DECL(STATIC void, initiate_descriptor_downloads,
|
|
|
|
(const routerstatus_t *source, int purpose, smartlist_t *digests,
|
|
|
|
int lo, int hi, int pds_flags));
|
2015-12-18 01:29:47 +01:00
|
|
|
STATIC int router_is_already_dir_fetching(const tor_addr_port_t *ap,
|
|
|
|
int serverdesc, int microdesc);
|
2014-09-23 18:21:08 +02:00
|
|
|
|
2012-08-09 19:47:42 +02:00
|
|
|
#endif
|
|
|
|
|
2010-07-21 17:08:11 +02:00
|
|
|
#endif
|
2015-10-06 17:32:37 +02:00
|
|
|
|