aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-03-08 09:54:54 -0500
committerDavid Goulet <dgoulet@torproject.org>2019-03-08 09:59:04 -0500
commitb4e44a371f077f5a9fca19f94e6ff5f604f3e9d3 (patch)
tree601185e91bb265391c69c5d47695a0def1204c68 /src
parent2e74edb53ef9ac417d8424a0785af839f83791ca (diff)
downloadtor-b4e44a371f077f5a9fca19f94e6ff5f604f3e9d3.tar.gz
tor-b4e44a371f077f5a9fca19f94e6ff5f604f3e9d3.zip
hs-v2: Copy needed information between service on prunning
Turns out that when reloading a tor configured with hidden service(s), we weren't copying all the needed information between the old service object to the new one. For instance, the desc_is_dirty timestamp wasn't which could lead to the service uploading its descriptor much later than it would need to. The replaycache wasn't also moved over and some intro point information as well. Fixes #23790 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src')
-rw-r--r--src/or/rendservice.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index da200d1381..32b856452d 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -532,6 +532,30 @@ rend_service_check_dir_and_add(smartlist_t *service_list,
}
}
+/* Copy relevant data from service src to dst while pruning the service lists.
+ * This should only be called during the pruning process which takes existing
+ * services and copy their data to the newly configured services. The src
+ * service replaycache will be set to NULL after this call. */
+static void
+copy_service_on_prunning(rend_service_t *dst, rend_service_t *src)
+{
+ tor_assert(dst);
+ tor_assert(src);
+
+ /* Keep the timestamps for when the content changed and the next upload
+ * time so we can properly upload the descriptor if needed for the new
+ * service object. */
+ dst->desc_is_dirty = src->desc_is_dirty;
+ dst->next_upload_time = src->next_upload_time;
+ /* Move the replaycache to the new object. */
+ dst->accepted_intro_dh_parts = src->accepted_intro_dh_parts;
+ src->accepted_intro_dh_parts = NULL;
+ /* Copy intro point information to destination service. */
+ dst->intro_period_started = src->intro_period_started;
+ dst->n_intro_circuits_launched = src->n_intro_circuits_launched;
+ dst->n_intro_points_wanted = src->n_intro_points_wanted;
+}
+
/** Set up rend_service_list, based on the values of HiddenServiceDir and
* HiddenServicePort in <b>options</b>. Return 0 on success and -1 on
* failure. (If <b>validate_only</b> is set, parse, warn and return as
@@ -812,6 +836,9 @@ rend_config_services(const or_options_t *options, int validate_only)
smartlist_add_all(new->expiring_nodes, old->expiring_nodes);
smartlist_clear(old->expiring_nodes);
smartlist_add(surviving_services, old);
+
+ /* Copy service flags to the new service object. */
+ copy_service_on_prunning(new, old);
break;
}
} SMARTLIST_FOREACH_END(old);