summaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-11-08 23:12:40 +0000
committerNick Mathewson <nickm@torproject.org>2004-11-08 23:12:40 +0000
commitcb5de85585c8084dd515baa351cb5d628adefcd1 (patch)
tree425ac23900b70514d3de5ef1187243177ae1558a /src/or/rendservice.c
parent8b9d7da59feea3078bf7f60ed562c1ce57498f4a (diff)
downloadtor-cb5de85585c8084dd515baa351cb5d628adefcd1.tar.gz
tor-cb5de85585c8084dd515baa351cb5d628adefcd1.zip
Separate validate from activate. Document undocumented stuff in config.c.
svn:r2711
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r--src/or/rendservice.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 91feccfdba..ebbc618d1b 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -178,19 +178,27 @@ static rend_service_port_config_t *parse_port_config(const char *string)
/** Set up rend_service_list, based on the values of HiddenServiceDir and
* HiddenServicePort in <b>options</b>. Return 0 on success and -1 on
- * failure.
+ * failure. (If <b>validate_only</b> is set, parse, warn and return as
+ * normal, but don't actually change the configured services.)
*/
-int rend_config_services(or_options_t *options)
+
+int rend_config_services(or_options_t *options, int validate_only)
{
struct config_line_t *line;
rend_service_t *service = NULL;
rend_service_port_config_t *portcfg;
- rend_service_free_all();
+
+ if (!validate_only)
+ rend_service_free_all();
for (line = options->RendConfigLines; line; line = line->next) {
if (!strcasecmp(line->key, "HiddenServiceDir")) {
- if (service)
- add_service(service);
+ if (service) {
+ if (validate_only)
+ rend_service_free(service);
+ else
+ add_service(service);
+ }
service = tor_malloc_zero(sizeof(rend_service_t));
service->directory = tor_strdup(line->value);
service->ports = smartlist_create();
@@ -225,8 +233,12 @@ int rend_config_services(or_options_t *options)
service->intro_exclude_nodes = tor_strdup(line->value);
}
}
- if (service)
- add_service(service);
+ if (service) {
+ if (validate_only)
+ rend_service_free(service);
+ else
+ add_service(service);
+ }
return 0;
}