summaryrefslogtreecommitdiff
path: root/shared/config-parser.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-07-05 19:04:13 +0200
committerDavid Härdeman <david@hardeman.nu>2020-07-05 19:04:13 +0200
commit2c9ba58d3142243b439dd83b254b1e6eba94d52c (patch)
tree3bda6601ff665951b271f5989869e7aa23afc972 /shared/config-parser.c
parent45af0d8c8603f037efe5f7bc1b1020b9cc42acdd (diff)
Add per-server announce setting
Diffstat (limited to 'shared/config-parser.c')
-rw-r--r--shared/config-parser.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 3309b96..6b91f3f 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -216,6 +216,9 @@ bool scfg_validate(struct server_config *scfg, const char **error)
switch (scfg->type) {
case SERVER_TYPE_ANNOUNCE:
+ if (scfg->announce == SERVER_ANNOUNCE_NEVER)
+ ERROR("announce policy never with an announce server");
+
if (scfg->announce_port == 0)
ERROR("missing announce port");
@@ -365,6 +368,19 @@ bool scfg_parse(struct server_config *scfg, char *buf, bool async,
ERROR("strdup failure");
break;
+ case SCFG_KEY_ANNOUNCE:
+ if (scfg->announce != SERVER_ANNOUNCE_UNDEFINED)
+ ERROR("announce policy defined multiple times");
+ else if (streq(value.str, "always"))
+ scfg->announce = SERVER_ANNOUNCE_ALWAYS;
+ else if (streq(value.str, "never"))
+ scfg->announce = SERVER_ANNOUNCE_NEVER;
+ else if (streq(value.str, "when-running"))
+ scfg->announce = SERVER_ANNOUNCE_WHEN_RUNNING;
+ else
+ ERROR("unknown announce policy");
+ break;
+
case SCFG_KEY_PORT:
if (scfg->announce_port != 0)
ERROR("port defined multiple times");
@@ -526,6 +542,7 @@ bool scfg_init(struct server_config *scfg, const char *filename)
scfg->type = SERVER_TYPE_UNDEFINED;
scfg->pretty_name = NULL;
+ scfg->announce = SERVER_ANNOUNCE_UNDEFINED;
scfg->announce_port = 0;
scfg->idle_timeout = 0;
scfg->stop_method = SERVER_STOP_METHOD_UNDEFINED;