aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2016-09-07 13:24:43 +1000
committerNick Mathewson <nickm@torproject.org>2016-09-13 10:13:56 -0400
commit65b2d34c9cb3434c26be71de6f725244444824a7 (patch)
treefa2cf44281dca611879dc3e341ae289fa5f554b8 /src/or/rendservice.c
parent41f96078c23e3ef1c39a853841332cac3e133a94 (diff)
downloadtor-65b2d34c9cb3434c26be71de6f725244444824a7.tar.gz
tor-65b2d34c9cb3434c26be71de6f725244444824a7.zip
Allow the unit tests to pass a service list to rend_service_load_all_keys
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r--src/or/rendservice.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index ed89268459..c91cd50fc1 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\"",