aboutsummaryrefslogtreecommitdiff
path: root/src/feature/dircache
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-01-15 11:43:14 -0500
committerNick Mathewson <nickm@torproject.org>2020-01-16 07:48:17 -0500
commit773bcf56290674cdc157f6e39894d31b366f8c50 (patch)
tree550b3336f71ae55ea335192c84cd88d87c702f2e /src/feature/dircache
parenta1bc471dd477864105cc13e8ab69ebd05619ea9b (diff)
downloadtor-773bcf56290674cdc157f6e39894d31b366f8c50.tar.gz
tor-773bcf56290674cdc157f6e39894d31b366f8c50.zip
Move dirclient-related functions out of dirserv, and reenable them
I had incorrectly identified these functions as dircache-only, when in fact they apply to everyone who acts a directory client.
Diffstat (limited to 'src/feature/dircache')
-rw-r--r--src/feature/dircache/dircache_stub.c30
-rw-r--r--src/feature/dircache/dirserv.c63
-rw-r--r--src/feature/dircache/dirserv.h5
3 files changed, 1 insertions, 97 deletions
diff --git a/src/feature/dircache/dircache_stub.c b/src/feature/dircache/dircache_stub.c
index dcab3bbbb9..f6804dad76 100644
--- a/src/feature/dircache/dircache_stub.c
+++ b/src/feature/dircache/dircache_stub.c
@@ -31,27 +31,6 @@ connection_dirserv_flushed_some(dir_connection_t *conn)
}
int
-directory_fetches_from_authorities(const or_options_t *options)
-{
- (void) options;
- return 0;
-}
-
-int
-directory_fetches_dir_info_early(const or_options_t *options)
-{
- (void) options;
- return 0;
-}
-
-int
-directory_fetches_dir_info_later(const or_options_t *options)
-{
- (void) options;
- return 0;
-}
-
-int
directory_caches_unknown_auth_certs(const or_options_t *options)
{
(void) options;
@@ -72,15 +51,6 @@ directory_permits_begindir_requests(const or_options_t *options)
return 0;
}
-int
-directory_too_idle_to_fetch_descriptors(const or_options_t *options,
- time_t now)
-{
- (void)options;
- (void)now;
- return 0;
-}
-
cached_dir_t *
dirserv_get_consensus(const char *flavor_name)
{
diff --git a/src/feature/dircache/dirserv.c b/src/feature/dircache/dirserv.c
index 7212614791..fb8db879a4 100644
--- a/src/feature/dircache/dirserv.c
+++ b/src/feature/dircache/dirserv.c
@@ -68,55 +68,7 @@ static cached_dir_t *lookup_cached_dir_by_fp(const uint8_t *fp);
/********************************************************************/
/* A set of functions to answer questions about how we'd like to behave
- * as a directory mirror/client. */
-
-/** Return 1 if we fetch our directory material directly from the
- * authorities, rather than from a mirror. */
-int
-directory_fetches_from_authorities(const or_options_t *options)
-{
- const routerinfo_t *me;
- uint32_t addr;
- int refuseunknown;
- if (options->FetchDirInfoEarly)
- return 1;
- if (options->BridgeRelay == 1)
- return 0;
- if (server_mode(options) &&
- router_pick_published_address(options, &addr, 1) < 0)
- return 1; /* we don't know our IP address; ask an authority. */
- refuseunknown = ! router_my_exit_policy_is_reject_star() &&
- should_refuse_unknown_exits(options);
- if (!dir_server_mode(options) && !refuseunknown)
- return 0;
- if (!server_mode(options) || !advertised_server_mode())
- return 0;
- me = router_get_my_routerinfo();
- if (!me || (!me->supports_tunnelled_dir_requests && !refuseunknown))
- return 0; /* if we don't service directory requests, return 0 too */
- return 1;
-}
-
-/** Return 1 if we should fetch new networkstatuses, descriptors, etc
- * on the "mirror" schedule rather than the "client" schedule.
- */
-int
-directory_fetches_dir_info_early(const or_options_t *options)
-{
- return directory_fetches_from_authorities(options);
-}
-
-/** Return 1 if we should fetch new networkstatuses, descriptors, etc
- * on a very passive schedule -- waiting long enough for ordinary clients
- * to probably have the info we want. These would include bridge users,
- * and maybe others in the future e.g. if a Tor client uses another Tor
- * client as a directory guard.
- */
-int
-directory_fetches_dir_info_later(const or_options_t *options)
-{
- return options->UseBridges != 0;
-}
+ * as a directory mirror */
/** Return true iff we want to serve certificates for authorities
* that we don't acknowledge as authorities ourself.
@@ -160,19 +112,6 @@ directory_permits_begindir_requests(const or_options_t *options)
return options->BridgeRelay != 0 || dir_server_mode(options);
}
-/** Return 1 if we have no need to fetch new descriptors. This generally
- * happens when we're not a dir cache and we haven't built any circuits
- * lately.
- */
-int
-directory_too_idle_to_fetch_descriptors(const or_options_t *options,
- time_t now)
-{
- return !directory_caches_dir_info(options) &&
- !options->FetchUselessDescriptors &&
- rep_hist_circbuilding_dormant(now);
-}
-
/********************************************************************/
/** Map from flavor name to the cached_dir_t for the v3 consensuses that we're
diff --git a/src/feature/dircache/dirserv.h b/src/feature/dircache/dirserv.h
index 895cef9484..29c5b9ad2c 100644
--- a/src/feature/dircache/dirserv.h
+++ b/src/feature/dircache/dirserv.h
@@ -80,14 +80,9 @@ int dir_split_resource_into_spoolable(const char *resource,
int *compressed_out,
int flags);
-int directory_fetches_from_authorities(const or_options_t *options);
-int directory_fetches_dir_info_early(const or_options_t *options);
-int directory_fetches_dir_info_later(const or_options_t *options);
int directory_caches_unknown_auth_certs(const or_options_t *options);
int directory_caches_dir_info(const or_options_t *options);
int directory_permits_begindir_requests(const or_options_t *options);
-int directory_too_idle_to_fetch_descriptors(const or_options_t *options,
- time_t now);
MOCK_DECL(cached_dir_t *, dirserv_get_consensus, (const char *flavor_name));
void dirserv_set_cached_consensus_networkstatus(const char *consensus,