summaryrefslogtreecommitdiff
path: root/src/or/networkstatus.c
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2016-11-30 11:07:48 +1100
committerteor <teor2345@gmail.com>2016-11-30 11:07:48 +1100
commit65d793fab2bf0a58d00080df8320693cb3a2dbeb (patch)
tree0c02f43af19541607aeb5531ae74e4345f4fc28a /src/or/networkstatus.c
parente5c608e535ef9a4c4fe951a277e3891c77de4908 (diff)
downloadtor-65d793fab2bf0a58d00080df8320693cb3a2dbeb.tar.gz
tor-65d793fab2bf0a58d00080df8320693cb3a2dbeb.zip
Fetch unknown certificates if FetchUselessDescriptors is true
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r--src/or/networkstatus.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 6cbcaf8c01..10157c6170 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -840,6 +840,29 @@ we_want_to_fetch_flavor(const or_options_t *options, int flavor)
return flavor == usable_consensus_flavor();
}
+/** Return true iff, given the options listed in <b>options</b>, we would like
+ * to fetch and store unknown authority certificates.
+ *
+ * For consensus and descriptor fetches, use we_want_to_fetch_flavor, and
+ * for serving fetched certificates, use directory_caches_unknown_auth_certs.
+ */
+int
+we_want_to_fetch_unknown_auth_certs(const or_options_t *options)
+{
+ if (authdir_mode_v3(options) ||
+ directory_caches_unknown_auth_certs((options))) {
+ /* We want to serve all certs to others, regardless if we would use
+ * them ourselves. */
+ return 1;
+ }
+ if (options->FetchUselessDescriptors) {
+ /* Unknown certificates are definitely useless. */
+ return 1;
+ }
+ /* Otherwise, don't fetch unknown certificates. */
+ return 0;
+}
+
/** How long will we hang onto a possibly live consensus for which we're
* fetching certs before we check whether there is a better one? */
#define DELAY_WHILE_FETCHING_CERTS (20*60)