mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Split routerlist.c into 4 separate modules
There are now separate modules for: * the list of router descriptors * the list of authorities and fallbacks * managing authority certificates * selecting random nodes
This commit is contained in:
parent
119159677b
commit
08e3b88f07
@ -105,7 +105,7 @@
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "lib/sandbox/sandbox.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "core/or/scheduler.h"
|
||||
#include "app/config/statefile.h"
|
||||
|
@ -80,9 +80,12 @@ LIBTOR_APP_A_SOURCES = \
|
||||
src/feature/hs/hs_stats.c \
|
||||
src/feature/hs_common/replaycache.c \
|
||||
src/feature/hs_common/shared_random_client.c \
|
||||
src/feature/nodelist/authcert.c \
|
||||
src/feature/nodelist/dirlist.c \
|
||||
src/feature/nodelist/microdesc.c \
|
||||
src/feature/nodelist/networkstatus.c \
|
||||
src/feature/nodelist/nodelist.c \
|
||||
src/feature/nodelist/node_select.c \
|
||||
src/feature/nodelist/parsecommon.c \
|
||||
src/feature/nodelist/routerlist.c \
|
||||
src/feature/nodelist/routerparse.c \
|
||||
@ -256,8 +259,10 @@ noinst_HEADERS += \
|
||||
src/feature/hs/hsdir_index_st.h \
|
||||
src/feature/hs_common/replaycache.h \
|
||||
src/feature/hs_common/shared_random_client.h \
|
||||
src/feature/nodelist/authcert.h \
|
||||
src/feature/nodelist/authority_cert_st.h \
|
||||
src/feature/nodelist/desc_store_st.h \
|
||||
src/feature/nodelist/dirlist.h \
|
||||
src/feature/nodelist/document_signature_st.h \
|
||||
src/feature/nodelist/extrainfo_st.h \
|
||||
src/feature/nodelist/microdesc.h \
|
||||
@ -268,6 +273,7 @@ noinst_HEADERS += \
|
||||
src/feature/nodelist/networkstatus_voter_info_st.h \
|
||||
src/feature/nodelist/node_st.h \
|
||||
src/feature/nodelist/nodelist.h \
|
||||
src/feature/nodelist/node_select.h \
|
||||
src/feature/nodelist/parsecommon.h \
|
||||
src/feature/nodelist/routerinfo_st.h \
|
||||
src/feature/nodelist/routerlist.h \
|
||||
|
@ -101,6 +101,8 @@
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "core/or/scheduler.h"
|
||||
|
@ -53,7 +53,7 @@
|
||||
#include "core/or/relay.h"
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "core/or/scheduler.h"
|
||||
#include "feature/nodelist/torcert.h"
|
||||
#include "feature/nodelist/networkstatus.h"
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "feature/rend/rendcommon.h"
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
@ -3007,4 +3008,3 @@ circuit_upgrade_circuits_from_guard_wait(void)
|
||||
|
||||
smartlist_free(to_upgrade);
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/relay/ext_orport.h"
|
||||
#include "core/or/scheduler.h"
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "core/or/or.h"
|
||||
#include "app/config/config.h"
|
||||
#include "core/or/reasons.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "lib/tls/tortls.h"
|
||||
|
||||
/***************************** Edge (stream) reasons **********************/
|
||||
|
@ -23,7 +23,9 @@
|
||||
#include "feature/nodelist/nodelist.h"
|
||||
#include "core/or/policies.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "feature/client/transports.h"
|
||||
|
||||
|
@ -133,7 +133,7 @@
|
||||
#include "feature/nodelist/nodelist.h"
|
||||
#include "core/or/policies.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "feature/client/transports.h"
|
||||
|
@ -77,6 +77,8 @@
|
||||
#include "feature/rend/rendservice.h"
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/hs_common/shared_random_client.h"
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/client/entrynodes.h" /* needed for guardfraction methods */
|
||||
|
@ -96,7 +96,7 @@
|
||||
#include "feature/nodelist/networkstatus.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/hs_common/shared_random_client.h"
|
||||
#include "feature/dirauth/shared_random_state.h"
|
||||
#include "feature/dircommon/voting_schedule.h"
|
||||
@ -1288,4 +1288,3 @@ set_num_srv_agreements(int32_t value)
|
||||
}
|
||||
|
||||
#endif /* defined(TOR_UNIT_TESTS) */
|
||||
|
||||
|
@ -40,7 +40,11 @@
|
||||
#include "feature/rend/rendservice.h"
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "lib/encoding/confline.h"
|
||||
|
@ -28,7 +28,9 @@
|
||||
#include "core/or/protover.h"
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "feature/nodelist/torcert.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "feature/rend/rendservice.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/hs_common/shared_random_client.h"
|
||||
#include "app/config/statefile.h"
|
||||
|
||||
|
1205
src/feature/nodelist/authcert.c
Normal file
1205
src/feature/nodelist/authcert.c
Normal file
File diff suppressed because it is too large
Load Diff
60
src/feature/nodelist/authcert.h
Normal file
60
src/feature/nodelist/authcert.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
* \file authcert.h
|
||||
* \brief Header file for authcert.c
|
||||
**/
|
||||
|
||||
#ifndef TOR_AUTHCERT_H
|
||||
#define TOR_AUTHCERT_H
|
||||
|
||||
#include "lib/testsupport/testsupport.h"
|
||||
|
||||
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_remove_old_certs(void);
|
||||
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 authority_cert_dl_looks_uncertain(const char *id_digest);
|
||||
int authority_cert_is_blacklisted(const authority_cert_t *cert);
|
||||
|
||||
void authority_cert_free_(authority_cert_t *cert);
|
||||
#define authority_cert_free(cert) \
|
||||
FREE_AND_NULL(authority_cert_t, authority_cert_free_, (cert))
|
||||
|
||||
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));
|
||||
|
||||
void authcert_free_all(void);
|
||||
|
||||
#endif
|
421
src/feature/nodelist/dirlist.c
Normal file
421
src/feature/nodelist/dirlist.c
Normal file
@ -0,0 +1,421 @@
|
||||
/* Copyright (c) 2001 Matej Pfajfar.
|
||||
* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
* \file dirlist.c
|
||||
* \brief Code to maintain our lists of directory authorities and
|
||||
* fallback directories.
|
||||
*
|
||||
* For the directory authorities, we have a list containing the public
|
||||
* identity key, and contact points, for each authority. The
|
||||
* authorities receive descriptors from relays, and publish consensuses,
|
||||
* descriptors, and microdescriptors. This list is pre-configured.
|
||||
*
|
||||
* Fallback directories are well-known, stable, but untrusted directory
|
||||
* caches that clients which have not yet bootstrapped can use to get
|
||||
* their first networkstatus consensus, in order to find out where the
|
||||
* Tor network really is. This list is pre-configured in
|
||||
* fallback_dirs.inc. Every authority also serves as a fallback.
|
||||
*
|
||||
* Both fallback directories and directory authorities are are
|
||||
* represented by a dir_server_t.
|
||||
*/
|
||||
|
||||
#include "core/or/or.h"
|
||||
|
||||
#include "app/config/config.h"
|
||||
#include "core/or/policies.h"
|
||||
#include "feature/control/control.h"
|
||||
#include "feature/dircache/directory.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/networkstatus.h"
|
||||
#include "feature/nodelist/nodelist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "lib/net/resolve.h"
|
||||
|
||||
#include "feature/dirclient/dir_server_st.h"
|
||||
#include "feature/nodelist/node_st.h"
|
||||
|
||||
/** Global list of a dir_server_t object for each directory
|
||||
* authority. */
|
||||
static smartlist_t *trusted_dir_servers = NULL;
|
||||
/** Global list of dir_server_t objects for all directory authorities
|
||||
* and all fallback directory servers. */
|
||||
static smartlist_t *fallback_dir_servers = NULL;
|
||||
|
||||
/** Return the number of directory authorities whose type matches some bit set
|
||||
* in <b>type</b> */
|
||||
int
|
||||
get_n_authorities(dirinfo_type_t type)
|
||||
{
|
||||
int n = 0;
|
||||
if (!trusted_dir_servers)
|
||||
return 0;
|
||||
SMARTLIST_FOREACH(trusted_dir_servers, dir_server_t *, ds,
|
||||
if (ds->type & type)
|
||||
++n);
|
||||
return n;
|
||||
}
|
||||
|
||||
/** Return a smartlist containing a list of dir_server_t * for all
|
||||
* known trusted dirservers. Callers must not modify the list or its
|
||||
* contents.
|
||||
*/
|
||||
smartlist_t *
|
||||
router_get_trusted_dir_servers_mutable(void)
|
||||
{
|
||||
if (!trusted_dir_servers)
|
||||
trusted_dir_servers = smartlist_new();
|
||||
|
||||
return trusted_dir_servers;
|
||||
}
|
||||
|
||||
smartlist_t *
|
||||
router_get_fallback_dir_servers_mutable(void)
|
||||
{
|
||||
if (!fallback_dir_servers)
|
||||
fallback_dir_servers = smartlist_new();
|
||||
|
||||
return fallback_dir_servers;
|
||||
}
|
||||
|
||||
const smartlist_t *
|
||||
router_get_trusted_dir_servers(void)
|
||||
{
|
||||
return router_get_trusted_dir_servers_mutable();
|
||||
}
|
||||
|
||||
const smartlist_t *
|
||||
router_get_fallback_dir_servers(void)
|
||||
{
|
||||
return router_get_fallback_dir_servers_mutable();
|
||||
}
|
||||
|
||||
/** Reset all internal variables used to count failed downloads of network
|
||||
* status objects. */
|
||||
void
|
||||
router_reset_status_download_failures(void)
|
||||
{
|
||||
mark_all_dirservers_up(fallback_dir_servers);
|
||||
}
|
||||
|
||||
/** Return the dir_server_t for the directory authority whose identity
|
||||
* key hashes to <b>digest</b>, or NULL if no such authority is known.
|
||||
*/
|
||||
dir_server_t *
|
||||
router_get_trusteddirserver_by_digest(const char *digest)
|
||||
{
|
||||
if (!trusted_dir_servers)
|
||||
return NULL;
|
||||
|
||||
SMARTLIST_FOREACH(trusted_dir_servers, dir_server_t *, ds,
|
||||
{
|
||||
if (tor_memeq(ds->digest, digest, DIGEST_LEN))
|
||||
return ds;
|
||||
});
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return the dir_server_t for the fallback dirserver whose identity
|
||||
* key hashes to <b>digest</b>, or NULL if no such fallback is in the list of
|
||||
* fallback_dir_servers. (fallback_dir_servers is affected by the FallbackDir
|
||||
* and UseDefaultFallbackDirs torrc options.)
|
||||
* The list of fallback directories includes the list of authorities.
|
||||
*/
|
||||
dir_server_t *
|
||||
router_get_fallback_dirserver_by_digest(const char *digest)
|
||||
{
|
||||
if (!fallback_dir_servers)
|
||||
return NULL;
|
||||
|
||||
if (!digest)
|
||||
return NULL;
|
||||
|
||||
SMARTLIST_FOREACH(fallback_dir_servers, dir_server_t *, ds,
|
||||
{
|
||||
if (tor_memeq(ds->digest, digest, DIGEST_LEN))
|
||||
return ds;
|
||||
});
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return 1 if any fallback dirserver's identity key hashes to <b>digest</b>,
|
||||
* or 0 if no such fallback is in the list of fallback_dir_servers.
|
||||
* (fallback_dir_servers is affected by the FallbackDir and
|
||||
* UseDefaultFallbackDirs torrc options.)
|
||||
* The list of fallback directories includes the list of authorities.
|
||||
*/
|
||||
int
|
||||
router_digest_is_fallback_dir(const char *digest)
|
||||
{
|
||||
return (router_get_fallback_dirserver_by_digest(digest) != NULL);
|
||||
}
|
||||
|
||||
/** Return the dir_server_t for the directory authority whose
|
||||
* v3 identity key hashes to <b>digest</b>, or NULL if no such authority
|
||||
* is known.
|
||||
*/
|
||||
MOCK_IMPL(dir_server_t *,
|
||||
trusteddirserver_get_by_v3_auth_digest, (const char *digest))
|
||||
{
|
||||
if (!trusted_dir_servers)
|
||||
return NULL;
|
||||
|
||||
SMARTLIST_FOREACH(trusted_dir_servers, dir_server_t *, ds,
|
||||
{
|
||||
if (tor_memeq(ds->v3_identity_digest, digest, DIGEST_LEN) &&
|
||||
(ds->type & V3_DIRINFO))
|
||||
return ds;
|
||||
});
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Mark as running every dir_server_t in <b>server_list</b>. */
|
||||
void
|
||||
mark_all_dirservers_up(smartlist_t *server_list)
|
||||
{
|
||||
if (server_list) {
|
||||
SMARTLIST_FOREACH_BEGIN(server_list, dir_server_t *, dir) {
|
||||
routerstatus_t *rs;
|
||||
node_t *node;
|
||||
dir->is_running = 1;
|
||||
node = node_get_mutable_by_id(dir->digest);
|
||||
if (node)
|
||||
node->is_running = 1;
|
||||
rs = router_get_mutable_consensus_status_by_id(dir->digest);
|
||||
if (rs) {
|
||||
rs->last_dir_503_at = 0;
|
||||
control_event_networkstatus_changed_single(rs);
|
||||
}
|
||||
} SMARTLIST_FOREACH_END(dir);
|
||||
}
|
||||
router_dir_info_changed();
|
||||
}
|
||||
|
||||
/** Return true iff <b>digest</b> is the digest of the identity key of a
|
||||
* trusted directory matching at least one bit of <b>type</b>. If <b>type</b>
|
||||
* is zero (NO_DIRINFO), or ALL_DIRINFO, any authority is okay. */
|
||||
int
|
||||
router_digest_is_trusted_dir_type(const char *digest, dirinfo_type_t type)
|
||||
{
|
||||
if (!trusted_dir_servers)
|
||||
return 0;
|
||||
if (authdir_mode(get_options()) && router_digest_is_me(digest))
|
||||
return 1;
|
||||
SMARTLIST_FOREACH(trusted_dir_servers, dir_server_t *, ent,
|
||||
if (tor_memeq(digest, ent->digest, DIGEST_LEN)) {
|
||||
return (!type) || ((type & ent->type) != 0);
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Create a directory server at <b>address</b>:<b>port</b>, with OR identity
|
||||
* key <b>digest</b> which has DIGEST_LEN bytes. If <b>address</b> is NULL,
|
||||
* add ourself. If <b>is_authority</b>, this is a directory authority. Return
|
||||
* the new directory server entry on success or NULL on failure. */
|
||||
static dir_server_t *
|
||||
dir_server_new(int is_authority,
|
||||
const char *nickname,
|
||||
const tor_addr_t *addr,
|
||||
const char *hostname,
|
||||
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 *ent;
|
||||
uint32_t a;
|
||||
char *hostname_ = NULL;
|
||||
|
||||
tor_assert(digest);
|
||||
|
||||
if (weight < 0)
|
||||
return NULL;
|
||||
|
||||
if (tor_addr_family(addr) == AF_INET)
|
||||
a = tor_addr_to_ipv4h(addr);
|
||||
else
|
||||
return NULL;
|
||||
|
||||
if (!hostname)
|
||||
hostname_ = tor_addr_to_str_dup(addr);
|
||||
else
|
||||
hostname_ = tor_strdup(hostname);
|
||||
|
||||
ent = tor_malloc_zero(sizeof(dir_server_t));
|
||||
ent->nickname = nickname ? tor_strdup(nickname) : NULL;
|
||||
ent->address = hostname_;
|
||||
ent->addr = a;
|
||||
ent->dir_port = dir_port;
|
||||
ent->or_port = or_port;
|
||||
ent->is_running = 1;
|
||||
ent->is_authority = is_authority;
|
||||
ent->type = type;
|
||||
ent->weight = weight;
|
||||
if (addrport_ipv6) {
|
||||
if (tor_addr_family(&addrport_ipv6->addr) != AF_INET6) {
|
||||
log_warn(LD_BUG, "Hey, I got a non-ipv6 addr as addrport_ipv6.");
|
||||
tor_addr_make_unspec(&ent->ipv6_addr);
|
||||
} else {
|
||||
tor_addr_copy(&ent->ipv6_addr, &addrport_ipv6->addr);
|
||||
ent->ipv6_orport = addrport_ipv6->port;
|
||||
}
|
||||
} else {
|
||||
tor_addr_make_unspec(&ent->ipv6_addr);
|
||||
}
|
||||
|
||||
memcpy(ent->digest, digest, DIGEST_LEN);
|
||||
if (v3_auth_digest && (type & V3_DIRINFO))
|
||||
memcpy(ent->v3_identity_digest, v3_auth_digest, DIGEST_LEN);
|
||||
|
||||
if (nickname)
|
||||
tor_asprintf(&ent->description, "directory server \"%s\" at %s:%d",
|
||||
nickname, hostname_, (int)dir_port);
|
||||
else
|
||||
tor_asprintf(&ent->description, "directory server at %s:%d",
|
||||
hostname_, (int)dir_port);
|
||||
|
||||
ent->fake_status.addr = ent->addr;
|
||||
tor_addr_copy(&ent->fake_status.ipv6_addr, &ent->ipv6_addr);
|
||||
memcpy(ent->fake_status.identity_digest, digest, DIGEST_LEN);
|
||||
if (nickname)
|
||||
strlcpy(ent->fake_status.nickname, nickname,
|
||||
sizeof(ent->fake_status.nickname));
|
||||
else
|
||||
ent->fake_status.nickname[0] = '\0';
|
||||
ent->fake_status.dir_port = ent->dir_port;
|
||||
ent->fake_status.or_port = ent->or_port;
|
||||
ent->fake_status.ipv6_orport = ent->ipv6_orport;
|
||||
|
||||
return ent;
|
||||
}
|
||||
|
||||
/** Create an authoritative directory server at
|
||||
* <b>address</b>:<b>port</b>, with identity key <b>digest</b>. If
|
||||
* <b>address</b> is NULL, add ourself. Return the new trusted directory
|
||||
* server entry on success or NULL if we couldn't add it. */
|
||||
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 *ipv6_addrport,
|
||||
const char *digest, const char *v3_auth_digest,
|
||||
dirinfo_type_t type, double weight)
|
||||
{
|
||||
uint32_t a;
|
||||
tor_addr_t addr;
|
||||
char *hostname=NULL;
|
||||
dir_server_t *result;
|
||||
|
||||
if (!address) { /* The address is us; we should guess. */
|
||||
if (resolve_my_address(LOG_WARN, get_options(),
|
||||
&a, NULL, &hostname) < 0) {
|
||||
log_warn(LD_CONFIG,
|
||||
"Couldn't find a suitable address when adding ourself as a "
|
||||
"trusted directory server.");
|
||||
return NULL;
|
||||
}
|
||||
if (!hostname)
|
||||
hostname = tor_dup_ip(a);
|
||||
} else {
|
||||
if (tor_lookup_hostname(address, &a)) {
|
||||
log_warn(LD_CONFIG,
|
||||
"Unable to lookup address for directory server at '%s'",
|
||||
address);
|
||||
return NULL;
|
||||
}
|
||||
hostname = tor_strdup(address);
|
||||
}
|
||||
tor_addr_from_ipv4h(&addr, a);
|
||||
|
||||
result = dir_server_new(1, nickname, &addr, hostname,
|
||||
dir_port, or_port,
|
||||
ipv6_addrport,
|
||||
digest,
|
||||
v3_auth_digest, type, weight);
|
||||
tor_free(hostname);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Return a new dir_server_t for a fallback directory server at
|
||||
* <b>addr</b>:<b>or_port</b>/<b>dir_port</b>, with identity key digest
|
||||
* <b>id_digest</b> */
|
||||
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)
|
||||
{
|
||||
return dir_server_new(0, NULL, addr, NULL, dir_port, or_port,
|
||||
addrport_ipv6,
|
||||
id_digest,
|
||||
NULL, ALL_DIRINFO, weight);
|
||||
}
|
||||
|
||||
/** Add a directory server to the global list(s). */
|
||||
void
|
||||
dir_server_add(dir_server_t *ent)
|
||||
{
|
||||
if (!trusted_dir_servers)
|
||||
trusted_dir_servers = smartlist_new();
|
||||
if (!fallback_dir_servers)
|
||||
fallback_dir_servers = smartlist_new();
|
||||
|
||||
if (ent->is_authority)
|
||||
smartlist_add(trusted_dir_servers, ent);
|
||||
|
||||
smartlist_add(fallback_dir_servers, ent);
|
||||
router_dir_info_changed();
|
||||
}
|
||||
|
||||
#define dir_server_free(val) \
|
||||
FREE_AND_NULL(dir_server_t, dir_server_free_, (val))
|
||||
|
||||
/** Free storage held in <b>ds</b>. */
|
||||
static void
|
||||
dir_server_free_(dir_server_t *ds)
|
||||
{
|
||||
if (!ds)
|
||||
return;
|
||||
|
||||
tor_free(ds->nickname);
|
||||
tor_free(ds->description);
|
||||
tor_free(ds->address);
|
||||
tor_free(ds);
|
||||
}
|
||||
|
||||
/** Remove all members from the list of dir servers. */
|
||||
void
|
||||
clear_dir_servers(void)
|
||||
{
|
||||
if (fallback_dir_servers) {
|
||||
SMARTLIST_FOREACH(fallback_dir_servers, dir_server_t *, ent,
|
||||
dir_server_free(ent));
|
||||
smartlist_clear(fallback_dir_servers);
|
||||
} else {
|
||||
fallback_dir_servers = smartlist_new();
|
||||
}
|
||||
if (trusted_dir_servers) {
|
||||
smartlist_clear(trusted_dir_servers);
|
||||
} else {
|
||||
trusted_dir_servers = smartlist_new();
|
||||
}
|
||||
router_dir_info_changed();
|
||||
}
|
||||
|
||||
void
|
||||
dirlist_free_all(void)
|
||||
{
|
||||
clear_dir_servers();
|
||||
smartlist_free(trusted_dir_servers);
|
||||
smartlist_free(fallback_dir_servers);
|
||||
trusted_dir_servers = fallback_dir_servers = NULL;
|
||||
}
|
47
src/feature/nodelist/dirlist.h
Normal file
47
src/feature/nodelist/dirlist.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
* \file dirlist.h
|
||||
* \brief Header file for dirlist.c
|
||||
**/
|
||||
|
||||
#ifndef TOR_DIRLIST_H
|
||||
#define TOR_DIRLIST_H
|
||||
|
||||
int get_n_authorities(dirinfo_type_t type);
|
||||
const smartlist_t *router_get_trusted_dir_servers(void);
|
||||
const smartlist_t *router_get_fallback_dir_servers(void);
|
||||
smartlist_t *router_get_trusted_dir_servers_mutable(void);
|
||||
smartlist_t *router_get_fallback_dir_servers_mutable(void);
|
||||
void mark_all_dirservers_up(smartlist_t *server_list);
|
||||
|
||||
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));
|
||||
|
||||
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)
|
||||
|
||||
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 clear_dir_servers(void);
|
||||
void dirlist_free_all(void);
|
||||
|
||||
#endif
|
@ -22,6 +22,7 @@
|
||||
#include "feature/nodelist/nodelist.h"
|
||||
#include "core/or/policies.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
|
||||
|
@ -63,6 +63,9 @@
|
||||
#include "core/or/protover.h"
|
||||
#include "core/or/relay.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "core/or/scheduler.h"
|
||||
|
1108
src/feature/nodelist/node_select.c
Normal file
1108
src/feature/nodelist/node_select.c
Normal file
File diff suppressed because it is too large
Load Diff
102
src/feature/nodelist/node_select.h
Normal file
102
src/feature/nodelist/node_select.h
Normal file
@ -0,0 +1,102 @@
|
||||
/* Copyright (c) 2001-2004, Roger Dingledine.
|
||||
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
||||
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
* \file node_select.h
|
||||
* \brief Header file for node_select.c
|
||||
**/
|
||||
|
||||
#ifndef TOR_NODE_SELECT_H
|
||||
#define TOR_NODE_SELECT_H
|
||||
|
||||
/** 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;
|
||||
|
||||
/** 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)
|
||||
|
||||
const routerstatus_t *router_pick_directory_server(dirinfo_type_t type,
|
||||
int flags);
|
||||
|
||||
int router_get_my_share_of_directory_requests(double *v3_share_out);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
#ifdef NODE_SELECT_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);
|
||||
STATIC int router_is_already_dir_fetching(const tor_addr_port_t *ap,
|
||||
int serverdesc, int microdesc);
|
||||
#endif
|
||||
|
||||
#endif
|
@ -59,6 +59,8 @@
|
||||
#include "core/or/protover.h"
|
||||
#include "feature/rend/rendservice.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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) */
|
||||
|
||||
|
@ -75,6 +75,7 @@
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "lib/sandbox/sandbox.h"
|
||||
#include "feature/hs_common/shared_random_client.h"
|
||||
#include "feature/nodelist/torcert.h"
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "app/config/statefile.h"
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "core/or/relay.h"
|
||||
#include "feature/stats/rephist.h"
|
||||
#include "feature/hs_common/replaycache.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "lib/encoding/confline.h"
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "feature/rend/rendclient.h"
|
||||
#include "feature/rend/rendservice.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "app/config/statefile.h"
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "feature/hs/hs_common.h"
|
||||
#include "feature/nodelist/networkstatus.h"
|
||||
#include "feature/rend/rendservice.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/nodelist.h"
|
||||
#include "test/test.h"
|
||||
#include "test/test_helpers.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define ROUTERPARSE_PRIVATE
|
||||
#define HIBERNATE_PRIVATE
|
||||
#define NETWORKSTATUS_PRIVATE
|
||||
#define NODE_SELECT_PRIVATE
|
||||
#define RELAY_PRIVATE
|
||||
|
||||
#include "core/or/or.h"
|
||||
@ -38,6 +39,9 @@
|
||||
#include "feature/nodelist/networkstatus.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "feature/rend/rendcommon.h"
|
||||
#include "feature/rend/rendcache.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "test/rend_test_helpers.h"
|
||||
#include "feature/nodelist/microdesc.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define HIBERNATE_PRIVATE
|
||||
#define NETWORKSTATUS_PRIVATE
|
||||
#define ROUTERLIST_PRIVATE
|
||||
#define NODE_SELECT_PRIVATE
|
||||
#define TOR_UNIT_TESTING
|
||||
#include "core/or/or.h"
|
||||
#include "app/config/config.h"
|
||||
@ -27,6 +28,8 @@
|
||||
#include "feature/nodelist/nodelist.h"
|
||||
#include "core/or/policies.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/node_select.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/routerset.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
|
@ -17,7 +17,8 @@
|
||||
#include "feature/nodelist/networkstatus.h"
|
||||
#include "feature/relay/router.h"
|
||||
#include "feature/relay/routerkeys.h"
|
||||
#include "feature/nodelist/routerlist.h"
|
||||
#include "feature/nodelist/authcert.h"
|
||||
#include "feature/nodelist/dirlist.h"
|
||||
#include "feature/nodelist/routerparse.h"
|
||||
#include "feature/hs_common/shared_random_client.h"
|
||||
#include "feature/dircommon/voting_schedule.h"
|
||||
|
Loading…
Reference in New Issue
Block a user