[tor-commits] [tor/master] Require live consensus to compute responsible HSDirs.

nickm at torproject.org nickm at torproject.org
Wed Jun 20 12:05:13 UTC 2018


commit 2520ee34c6d1b5eb83a6c3ffdaf1e8b3013b619f
Author: George Kadianakis <desnacked at riseup.net>
Date:   Wed Jun 13 13:27:00 2018 +0300

    Require live consensus to compute responsible HSDirs.
    
    Here is how this changes the HSv3 client-side and service-side:
    
    For service side we already required live consensus to upload descriptors (see
    9e900d1db7c8c9e164b5b14d5cdd4099c1ce45f0) so we should never get there without
    a live consensus.
    
    For the client-side we now require a live consensus to attempt to connect to
    HS.  While this changes the client behavior in principle, it doesn't really
    change it, because we always required live consensus to set HSDir indices, so
    before this patch a client with no live consensus would try to compute
    responsible HSDirs without any HSDir indices and bug out. This makes the client
    behavior more consistent, by requiring a live consensus (and hence a
    semi-synced clock) for the client to connect to an HS entirely.
    
    The alternative would have been to allow setting HSDir indices with a non-live
    consensus, but this would cause the various problems outlined by commit
    b89d2fa1db2379bffd2e2b4c851c3facc57b6ed8.
---
 src/or/hs_common.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index 3081ad216..6f51e1d13 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -1332,15 +1332,17 @@ hs_get_responsible_hsdirs(const ed25519_public_key_t *blinded_pk,
 
   sorted_nodes = smartlist_new();
 
+  /* Make sure we actually have a live consensus */
+  networkstatus_t *c = networkstatus_get_live_consensus(approx_time());
+  if (!c || smartlist_len(c->routerstatus_list) == 0) {
+      log_warn(LD_REND, "No live consensus so we can't get the responsible "
+               "hidden service directories.");
+      goto done;
+  }
+
   /* Add every node_t that support HSDir v3 for which we do have a valid
    * hsdir_index already computed for them for this consensus. */
   {
-    networkstatus_t *c = networkstatus_get_latest_consensus();
-    if (!c || smartlist_len(c->routerstatus_list) == 0) {
-      log_warn(LD_REND, "No valid consensus so we can't get the responsible "
-                        "hidden service directories.");
-      goto done;
-    }
     SMARTLIST_FOREACH_BEGIN(c->routerstatus_list, const routerstatus_t *, rs) {
       /* Even though this node_t object won't be modified and should be const,
        * we can't add const object in a smartlist_t. */





More information about the tor-commits mailing list