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

[tor-commits] [tor/master] prop224: Make INTRODUCE2 min/max a consensus param



commit 670cecaf669d87bd3bdb52ef1848cf6d73725746
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Tue May 9 16:05:28 2017 -0400

    prop224: Make INTRODUCE2 min/max a consensus param
    
    Introduction point are rotated either if we get X amounts of INTRODUCE2 cells
    on it or a time based expiration. This commit adds two consensus parameters
    which are the min and max value bounding the random value X.
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/or/hs_service.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 42523ed85..f72f0f30e 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -203,6 +203,30 @@ service_clear_config(hs_service_config_t *config)
   memset(config, 0, sizeof(*config));
 }
 
+/* Return the number of minimum INTRODUCE2 cell defined by a consensus
+ * parameter or the default value. */
+static int32_t
+get_intro_point_min_introduce2(void)
+{
+  /* The [0, 2147483647] range is quite large to accomodate anything we decide
+   * in the future. */
+  return networkstatus_get_param(NULL, "hs_intro_min_introduce2",
+                                 INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS,
+                                 0, INT32_MAX);
+}
+
+/* Return the number of maximum INTRODUCE2 cell defined by a consensus
+ * parameter or the default value. */
+static int32_t
+get_intro_point_max_introduce2(void)
+{
+  /* The [0, 2147483647] range is quite large to accomodate anything we decide
+   * in the future. */
+  return networkstatus_get_param(NULL, "hs_intro_max_introduce2",
+                                 INTRO_POINT_MAX_LIFETIME_INTRODUCTIONS,
+                                 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
@@ -274,10 +298,10 @@ service_intro_point_new(const extend_info_t *ei, unsigned int is_legacy)
    * term keys. */
   ed25519_keypair_generate(&ip->auth_key_kp, 0);
 
-  /* XXX: These will be controlled by consensus params. (#20961) */
   ip->introduce2_max =
-    crypto_rand_int_range(INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS,
-                          INTRO_POINT_MAX_LIFETIME_INTRODUCTIONS);
+    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);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits