[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Allow the unit tests to pass a service list to rend_service_load_all_keys
commit 65b2d34c9cb3434c26be71de6f725244444824a7
Author: teor <teor2345@xxxxxxxxx>
Date: Wed Sep 7 13:24:43 2016 +1000
Allow the unit tests to pass a service list to rend_service_load_all_keys
---
src/or/rendservice.c | 20 ++++++++++++++++----
src/or/rendservice.h | 2 +-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index ed89268..c91cd50 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -1153,12 +1153,24 @@ rend_service_poison_new_single_onion_dirs(const smartlist_t *service_list)
}
/** Load and/or generate private keys for all hidden services, possibly
- * including keys for client authorization. Return 0 on success, -1 on
- * failure. */
+ * including keys for client authorization.
+ * If a <b>service_list</b> is provided, treat it as the list of hidden
+ * services (used in unittests). Otherwise, require that rend_service_list is
+ * not NULL.
+ * Return 0 on success, -1 on failure. */
int
-rend_service_load_all_keys(void)
+rend_service_load_all_keys(const smartlist_t *service_list)
{
- SMARTLIST_FOREACH_BEGIN(rend_service_list, rend_service_t *, s) {
+ const smartlist_t *s_list;
+ /* If no special service list is provided, then just use the global one. */
+ if (!service_list) {
+ tor_assert(rend_service_list);
+ s_list = rend_service_list;
+ } else {
+ s_list = service_list;
+ }
+
+ SMARTLIST_FOREACH_BEGIN(s_list, rend_service_t *, s) {
if (s->private_key)
continue;
log_info(LD_REND, "Loading hidden-service keys from \"%s\"",
diff --git a/src/or/rendservice.h b/src/or/rendservice.h
index 0cf448e..ec32262 100644
--- a/src/or/rendservice.h
+++ b/src/or/rendservice.h
@@ -123,7 +123,7 @@ STATIC void rend_service_free(rend_service_t *service);
int num_rend_services(void);
int rend_config_services(const or_options_t *options, int validate_only);
-int rend_service_load_all_keys(void);
+int rend_service_load_all_keys(const smartlist_t *service_list);
void rend_services_add_filenames_to_lists(smartlist_t *open_lst,
smartlist_t *stat_lst);
void rend_consider_services_intro_points(void);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits