[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor] 38/77: hs_pow: check for expired params in can_client_refetch_desc



This is an automated email from the git hooks/post-receive script.

dgoulet pushed a commit to branch main
in repository tor.

commit a0b9f3546eeead024b480cd19eed108fc3e8970a
Author: Micah Elizabeth Scott <beth@xxxxxxxxxxxxxx>
AuthorDate: Mon Feb 27 13:11:49 2023 -0800

    hs_pow: check for expired params in can_client_refetch_desc
    
    Without this check, we never actually refetch the hs descriptor
    when PoW parameters expire, because can_client_refetch_desc
    deems the descriptor to be still good.
    
    Signed-off-by: Micah Elizabeth Scott <beth@xxxxxxxxxxxxxx>
---
 src/feature/hs/hs_client.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/feature/hs/hs_client.c b/src/feature/hs/hs_client.c
index 038f76c5b8..56547de7e7 100644
--- a/src/feature/hs/hs_client.c
+++ b/src/feature/hs/hs_client.c
@@ -1451,9 +1451,20 @@ can_client_refetch_desc(const ed25519_public_key_t *identity_pk,
   /* Check if fetching a desc for this HS is useful to us right now */
   {
     const hs_descriptor_t *cached_desc = NULL;
+    int has_usable_intro = false;
+    int has_expired_hs_pow = false;
+
     cached_desc = hs_cache_lookup_as_client(identity_pk);
-    if (cached_desc && hs_client_any_intro_points_usable(identity_pk,
-                                                         cached_desc)) {
+    if (cached_desc) {
+      has_usable_intro = hs_client_any_intro_points_usable(identity_pk,
+                                                           cached_desc);
+      if (cached_desc->encrypted_data.pow_params) {
+        has_expired_hs_pow =
+          cached_desc->encrypted_data.pow_params->expiration_time <
+          approx_time();
+      }
+    }
+    if (has_usable_intro && !has_expired_hs_pow) {
       log_info(LD_GENERAL, "We would fetch a v3 hidden service descriptor "
                            "but we already have a usable descriptor.");
       status = HS_CLIENT_FETCH_HAVE_DESC;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits