aboutsummaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-03-10 12:18:52 +0100
committerNick Mathewson <nickm@torproject.org>2017-03-17 11:15:43 -0400
commit23ae5b655b9d94d62c6c9296cb8cc2b33ae345d7 (patch)
treebcd27dc338a8c1473b0f5be5d8436ff863bfead8 /src/or/main.c
parent85dccce35db907221df38da7bd789f28f7d1e2f9 (diff)
downloadtor-23ae5b655b9d94d62c6c9296cb8cc2b33ae345d7.tar.gz
tor-23ae5b655b9d94d62c6c9296cb8cc2b33ae345d7.zip
Make MIN_ONION_KEY_LIFETIME a consensus parameter defined value.
This patch turns `MIN_ONION_KEY_LIFETIME` into a new function `get_onion_key_lifetime()` which gets its value from a network consensus parameter named "onion-key-rotation-days". This allows us to tune the value at a later point in time with no code modifications. We also bump the default onion key lifetime from 7 to 28 days as per proposal #274. See: https://bugs.torproject.org/21641
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 475587eacd..107a4842a9 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1472,15 +1472,16 @@ run_scheduled_events(time_t now)
pt_configure_remaining_proxies();
}
-/* Periodic callback: Every MIN_ONION_KEY_LIFETIME seconds, rotate the onion
- * keys, shut down and restart all cpuworkers, and update our descriptor if
- * necessary.
+/* Periodic callback: rotate the onion keys after the period defined by the
+ * "onion-key-rotation-days" consensus parameter, shut down and restart all
+ * cpuworkers, and update our descriptor if necessary.
*/
static int
rotate_onion_key_callback(time_t now, const or_options_t *options)
{
if (server_mode(options)) {
- time_t rotation_time = get_onion_key_set_at()+MIN_ONION_KEY_LIFETIME;
+ int onion_key_lifetime = get_onion_key_lifetime();
+ time_t rotation_time = get_onion_key_set_at()+onion_key_lifetime;
if (rotation_time > now) {
return safe_timer_diff(now, rotation_time);
}
@@ -1493,7 +1494,7 @@ rotate_onion_key_callback(time_t now, const or_options_t *options)
}
if (advertised_server_mode() && !options->DisableNetwork)
router_upload_dir_desc_to_dirservers(0);
- return MIN_ONION_KEY_LIFETIME;
+ return onion_key_lifetime;
}
return PERIODIC_EVENT_NO_UPDATE;
}