summaryrefslogtreecommitdiff
path: root/src/or/hs_service.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-05-09 16:10:14 -0400
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:33 -0400
commitf0e02e3a141150f02bafaab35d6ab48c79d78d6d (patch)
treea76493c7245058b34f165bae88a89f3259ca9fff /src/or/hs_service.c
parent670cecaf669d87bd3bdb52ef1848cf6d73725746 (diff)
downloadtor-f0e02e3a141150f02bafaab35d6ab48c79d78d6d.tar.gz
tor-f0e02e3a141150f02bafaab35d6ab48c79d78d6d.zip
prop224: Make intro point min/max lifetime a consensus param
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_service.c')
-rw-r--r--src/or/hs_service.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index f72f0f30e6..55c9b689f8 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -227,6 +227,30 @@ get_intro_point_max_introduce2(void)
0, INT32_MAX);
}
+/* Return the minimum lifetime of an introduction point defined by a consensus
+ * parameter or the default value. */
+static int32_t
+get_intro_point_min_lifetime(void)
+{
+ /* The [0, 2147483647] range is quite large to accomodate anything we decide
+ * in the future. */
+ return networkstatus_get_param(NULL, "hs_intro_min_lifetime",
+ INTRO_POINT_LIFETIME_MIN_SECONDS,
+ 0, INT32_MAX);
+}
+
+/* Return the maximum lifetime of an introduction point defined by a consensus
+ * parameter or the default value. */
+static int32_t
+get_intro_point_max_lifetime(void)
+{
+ /* The [0, 2147483647] range is quite large to accomodate anything we decide
+ * in the future. */
+ return networkstatus_get_param(NULL, "hs_intro_max_lifetime",
+ INTRO_POINT_LIFETIME_MAX_SECONDS,
+ 0, INT32_MAX);
+}
+
/* Helper: Function that needs to return 1 for the HT for each loop which
* frees every service in an hash map. */
static int
@@ -301,10 +325,9 @@ service_intro_point_new(const extend_info_t *ei, unsigned int is_legacy)
ip->introduce2_max =
crypto_rand_int_range(get_intro_point_min_introduce2(),
get_intro_point_max_introduce2());
- /* XXX: These will be controlled by consensus params. (#20961) */
ip->time_to_expire = time(NULL) +
- crypto_rand_int_range(INTRO_POINT_LIFETIME_MIN_SECONDS,
- INTRO_POINT_LIFETIME_MAX_SECONDS);
+ crypto_rand_int_range(get_intro_point_min_lifetime(),
+ get_intro_point_max_lifetime());
ip->replay_cache = replaycache_new(0, 0);
/* Initialize the base object. We don't need the certificate object. */