aboutsummaryrefslogtreecommitdiff
path: root/src/feature/hs_common
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2021-01-11 16:01:22 -0500
committerDavid Goulet <dgoulet@torproject.org>2021-01-12 09:46:35 -0500
commit04b0263974c7ad1327e7a193884cf31d55f7949a (patch)
tree2645b30b1b01442d6c10e4480cf81a40141d139b /src/feature/hs_common
parent6c0f15500b3aa027c90d1c397d4504bb2f4dd41b (diff)
downloadtor-04b0263974c7ad1327e7a193884cf31d55f7949a.tar.gz
tor-04b0263974c7ad1327e7a193884cf31d55f7949a.zip
hs-v3: Require reasonably live consensus
Some days before this commit, the network experienced a DDoS on the directory authorities that prevented them to generate a consensus for more than 5 hours straight. That in turn entirely disabled onion service v3, client and service side, due to the subsystem requiring a live consensus to function properly. We know require a reasonably live consensus which means that the HSv3 subsystem will to its job for using the best consensus tor can find. If the entire network is using an old consensus, than this should be alright. If the service happens to use a live consensus while a client is not, it should still work because the client will use the current SRV it sees which might be the previous SRV for the service for which it still publish descriptors for. If the service is using an old one and somehow can't get a new one while clients are on a new one, then reachability issues might arise. However, this is a situation we already have at the moment since the service will simply not work if it doesn't have a live consensus while a client has one. Fixes #40237 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/hs_common')
-rw-r--r--src/feature/hs_common/shared_random_client.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/feature/hs_common/shared_random_client.c b/src/feature/hs_common/shared_random_client.c
index 3d6be94080..ead5d681a9 100644
--- a/src/feature/hs_common/shared_random_client.c
+++ b/src/feature/hs_common/shared_random_client.c
@@ -13,6 +13,7 @@
#include "app/config/config.h"
#include "feature/dircommon/voting_schedule.h"
+#include "feature/nodelist/microdesc.h"
#include "feature/nodelist/networkstatus.h"
#include "lib/encoding/binascii.h"
@@ -37,7 +38,9 @@ int
get_voting_interval(void)
{
int interval;
- networkstatus_t *consensus = networkstatus_get_live_consensus(time(NULL));
+ networkstatus_t *consensus =
+ networkstatus_get_reasonably_live_consensus(time(NULL),
+ usable_consensus_flavor());
if (consensus) {
interval = (int)(consensus->fresh_until - consensus->valid_after);
@@ -142,7 +145,8 @@ sr_get_current(const networkstatus_t *ns)
if (ns) {
consensus = ns;
} else {
- consensus = networkstatus_get_live_consensus(approx_time());
+ consensus = networkstatus_get_reasonably_live_consensus(approx_time(),
+ usable_consensus_flavor());
}
/* Ideally we would never be asked for an SRV without a live consensus. Make
* sure this assumption is correct. */
@@ -165,7 +169,8 @@ sr_get_previous(const networkstatus_t *ns)
if (ns) {
consensus = ns;
} else {
- consensus = networkstatus_get_live_consensus(approx_time());
+ consensus = networkstatus_get_reasonably_live_consensus(approx_time(),
+ usable_consensus_flavor());
}
/* Ideally we would never be asked for an SRV without a live consensus. Make
* sure this assumption is correct. */
@@ -237,10 +242,14 @@ sr_state_get_start_time_of_current_protocol_run(void)
int voting_interval = get_voting_interval();
time_t beginning_of_curr_round;
- /* This function is not used for voting purposes, so if we have a live
- consensus, use its valid-after as the beginning of the current round,
- otherwise resort to the voting schedule which should always exist. */
- networkstatus_t *ns = networkstatus_get_live_consensus(approx_time());
+ /* This function is not used for voting purposes, so if we have a reasonably
+ * live consensus, use its valid-after as the beginning of the current
+ * round. If we have no consensus but we're an authority, use our own
+ * schedule. Otherwise, try using our view of the voting interval to figure
+ * out when the current round _should_ be starting. */
+ networkstatus_t *ns =
+ networkstatus_get_reasonably_live_consensus(approx_time(),
+ usable_consensus_flavor());
if (ns) {
beginning_of_curr_round = ns->valid_after;
} else {