]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
prop224: Make circuit prediction aware of v3 services
authorDavid Goulet <dgoulet@torproject.org>
Tue, 11 Jul 2017 15:18:23 +0000 (11:18 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 9 Aug 2017 00:29:34 +0000 (20:29 -0400)
Signed-off-by: David Goulet <dgoulet@torproject.org>
src/or/circuituse.c
src/or/hs_service.c
src/or/hs_service.h

index b19f9ed46fbc300e8351ed87dfb5e55639a359ab..5292dc01db15ca13bf505d7dfa72f0441b6d4ff1 100644 (file)
@@ -1116,7 +1116,7 @@ needs_exit_circuits(time_t now, int *needs_uptime, int *needs_capacity)
 STATIC int
 needs_hs_server_circuits(int num_uptime_internal)
 {
-  return (rend_num_services() &&
+  return ((rend_num_services() || hs_service_get_num_services()) &&
           num_uptime_internal < SUFFICIENT_UPTIME_INTERNAL_HS_SERVERS &&
           router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN);
 }
index d717b9ce2f232edf01f24d624bec39fead3bf802..a20de94b117eaf9212ef5522c80f487c4a1475ba 100644 (file)
@@ -2390,6 +2390,16 @@ service_add_fnames_to_list(const hs_service_t *service, smartlist_t *list)
 /* Public API */
 /* ========== */
 
+/* Return the number of service we have configured and usable. */
+unsigned int
+hs_service_get_num_services(void)
+{
+  if (hs_service_map == NULL) {
+    return 0;
+  }
+  return HT_SIZE(hs_service_map);
+}
+
 /* Called once an introduction circuit is closed. If the circuit doesn't have
  * a v3 identifier, it is ignored. */
 void
index bc29c3d82b32c4357bbbbdb74943862acfc2b361..f46c4f51a604653e4c7611dceda00dca9ace4106 100644 (file)
@@ -253,6 +253,7 @@ void hs_service_free_all(void);
 hs_service_t *hs_service_new(const or_options_t *options);
 void hs_service_free(hs_service_t *service);
 
+unsigned int hs_service_get_num_services(void);
 void hs_service_stage_services(const smartlist_t *service_list);
 int hs_service_load_all_keys(void);
 void hs_service_lists_fnames_for_sandbox(smartlist_t *file_list,