|
@@ -79,6 +79,10 @@ static int rend_service_check_private_dir(const or_options_t *options,
|
|
|
static int rend_service_check_private_dir_impl(const or_options_t *options,
|
|
|
const rend_service_t *s,
|
|
|
int create);
|
|
|
+static const smartlist_t* rend_get_service_list(
|
|
|
+ const smartlist_t* substitute_service_list);
|
|
|
+static smartlist_t* rend_get_service_list_mutable(
|
|
|
+ smartlist_t* substitute_service_list);
|
|
|
|
|
|
|
|
|
* a real port on some IP.
|
|
@@ -124,8 +128,44 @@ static const char *hostname_fname = "hostname";
|
|
|
static const char *client_keys_fname = "client_keys";
|
|
|
static const char *sos_poison_fname = "onion_service_non_anonymous";
|
|
|
|
|
|
+
|
|
|
+ */
|
|
|
+static smartlist_t *rend_service_list = NULL;
|
|
|
+
|
|
|
+
|
|
|
+static const smartlist_t*
|
|
|
+rend_get_service_list(const smartlist_t* substitute_service_list)
|
|
|
+{
|
|
|
+
|
|
|
+ * rend_get_service_list_mutable does not actually modify the list */
|
|
|
+ return rend_get_service_list_mutable((smartlist_t*)substitute_service_list);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ * If substitute_service_list is not NULL, return it.
|
|
|
+ * Otherwise, check if the global rend_service_list is non-NULL, and if so,
|
|
|
+ * return it.
|
|
|
+ * Otherwise, return NULL.
|
|
|
+ * */
|
|
|
+static smartlist_t*
|
|
|
+rend_get_service_list_mutable(smartlist_t* substitute_service_list)
|
|
|
+{
|
|
|
+ if (substitute_service_list) {
|
|
|
+ return substitute_service_list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (BUG(!rend_service_list)) {
|
|
|
+
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ return rend_service_list;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
-*/
|
|
|
+ */
|
|
|
static unsigned int
|
|
|
rend_service_is_ephemeral(const struct rend_service_t *s)
|
|
|
{
|
|
@@ -140,10 +180,6 @@ rend_service_escaped_dir(const struct rend_service_t *s)
|
|
|
return rend_service_is_ephemeral(s) ? "[EPHEMERAL]" : escaped(s->directory);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- */
|
|
|
-static smartlist_t *rend_service_list = NULL;
|
|
|
-
|
|
|
|
|
|
int
|
|
|
num_rend_services(void)
|
|
@@ -239,17 +275,10 @@ rend_add_service(smartlist_t *service_list, rend_service_t *service)
|
|
|
int i;
|
|
|
rend_service_port_config_t *p;
|
|
|
|
|
|
- smartlist_t *s_list;
|
|
|
-
|
|
|
- if (!service_list) {
|
|
|
- if (BUG(!rend_service_list)) {
|
|
|
-
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- s_list = rend_service_list;
|
|
|
- } else {
|
|
|
- s_list = service_list;
|
|
|
+
|
|
|
+ smartlist_t *s_list = rend_get_service_list_mutable(service_list);
|
|
|
+ if (BUG(!s_list)) {
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
service->intro_nodes = smartlist_new();
|
|
@@ -502,18 +531,7 @@ rend_service_check_dir_and_add(smartlist_t *service_list,
|
|
|
return 0;
|
|
|
} else {
|
|
|
|
|
|
- smartlist_t *s_list = NULL;
|
|
|
-
|
|
|
- if (!service_list) {
|
|
|
- if (BUG(!rend_service_list)) {
|
|
|
-
|
|
|
- * it */
|
|
|
- return -1;
|
|
|
- }
|
|
|
- s_list = rend_service_list;
|
|
|
- } else {
|
|
|
- s_list = service_list;
|
|
|
- }
|
|
|
+ smartlist_t *s_list = rend_get_service_list_mutable(service_list);
|
|
|
|
|
|
* are NULL, and validate_only is false, we exit earlier in the function
|
|
|
*/
|
|
@@ -1261,15 +1279,10 @@ rend_service_poison_new_single_onion_dir(const rend_service_t *s,
|
|
|
int
|
|
|
rend_service_load_all_keys(const smartlist_t *service_list)
|
|
|
{
|
|
|
- const smartlist_t *s_list = NULL;
|
|
|
-
|
|
|
- if (!service_list) {
|
|
|
- if (BUG(!rend_service_list)) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
- s_list = rend_service_list;
|
|
|
- } else {
|
|
|
- s_list = service_list;
|
|
|
+
|
|
|
+ const smartlist_t *s_list = rend_get_service_list(service_list);
|
|
|
+ if (BUG(!s_list)) {
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
SMARTLIST_FOREACH_BEGIN(s_list, rend_service_t *, s) {
|