summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-07-11 11:18:23 -0400
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:34 -0400
commit6c3d525c361adac1ad769f87a343fe3e9d2b050b (patch)
treeae9debf88c6d54872f0d4e2ee3212d859397bfaf /src
parent713eb08bc9582b49e8073122fb68c3fac5bae188 (diff)
downloadtor-6c3d525c361adac1ad769f87a343fe3e9d2b050b.tar.gz
tor-6c3d525c361adac1ad769f87a343fe3e9d2b050b.zip
prop224: Make circuit prediction aware of v3 services
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src')
-rw-r--r--src/or/circuituse.c2
-rw-r--r--src/or/hs_service.c10
-rw-r--r--src/or/hs_service.h1
3 files changed, 12 insertions, 1 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index b19f9ed46f..5292dc01db 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -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);
}
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index d717b9ce2f..a20de94b11 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -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
diff --git a/src/or/hs_service.h b/src/or/hs_service.h
index bc29c3d82b..f46c4f51a6 100644
--- a/src/or/hs_service.h
+++ b/src/or/hs_service.h
@@ -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,