diff options
author | George Kadianakis <desnacked@riseup.net> | 2018-07-12 16:51:31 +0300 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-07-17 15:57:46 -0400 |
commit | 4cfade2f4682fa2554f79b2edf51f9dde8f924dc (patch) | |
tree | 0ce8d8274e9a33ad0f0ad8dc503988665094ba6d /src | |
parent | 0140052a356cdcfe0e2da25aee6b8c376815528c (diff) | |
download | tor-4cfade2f4682fa2554f79b2edf51f9dde8f924dc.tar.gz tor-4cfade2f4682fa2554f79b2edf51f9dde8f924dc.zip |
Set revision counter before uploading, not during building.
We only build a descriptor once, and we just re-encode it (and change its intro
points if needed) before uploading.
Hence we should set the revision counter before uploading, not during building.
Diffstat (limited to 'src')
-rw-r--r-- | src/or/hs_service.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/or/hs_service.c b/src/or/hs_service.c index 3500e497bd..5430ef4d87 100644 --- a/src/or/hs_service.c +++ b/src/or/hs_service.c @@ -1446,15 +1446,11 @@ build_service_desc_keys(const hs_service_t *service, * the update function. On success, desc_out will point to the newly allocated * descriptor object. * - * If <b>is_current</b> is true, this is the current service descriptor, - * otherwise it's the next one. - * * This can error if we are unable to create keys or certificate. */ static void build_service_descriptor(hs_service_t *service, time_t now, uint64_t time_period_num, - hs_service_descriptor_t **desc_out, - bool is_current) + hs_service_descriptor_t **desc_out) { char *encoded_desc; hs_service_descriptor_t *desc; @@ -1480,9 +1476,6 @@ build_service_descriptor(hs_service_t *service, time_t now, goto err; } - /* Set the revision counter for this descriptor */ - set_descriptor_revision_counter(desc, now, is_current); - /* Let's make sure that we've created a descriptor that can actually be * encoded properly. This function also checks if the encoded output is * decodable after. */ @@ -1547,9 +1540,9 @@ build_descriptors_for_new_service(hs_service_t *service, time_t now) /* Build descriptors. */ build_service_descriptor(service, now, current_desc_tp, - &service->desc_current, 1); + &service->desc_current); build_service_descriptor(service, now, next_desc_tp, - &service->desc_next, 0); + &service->desc_next); log_info(LD_REND, "Hidden service %s has just started. Both descriptors " "built. Now scheduled for upload.", safe_str_client(service->onion_address)); @@ -1580,7 +1573,7 @@ build_all_descriptors(time_t now) if (service->desc_next == NULL) { build_service_descriptor(service, now, hs_get_next_time_period_num(0), - &service->desc_next, 0); + &service->desc_next); log_info(LD_REND, "Hidden service %s next descriptor successfully " "built. Now scheduled for upload.", safe_str_client(service->onion_address)); @@ -2631,6 +2624,10 @@ run_upload_descriptor_event(time_t now) * accurate because all circuits have been established. */ build_desc_intro_points(service, desc, now); + /* Set the desc revision counter right before uploading */ + set_descriptor_revision_counter(desc, approx_time(), + service->desc_current == desc); + upload_descriptor_to_all(service, desc); } FOR_EACH_DESCRIPTOR_END; } FOR_EACH_SERVICE_END; |