summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/config-parser.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 850bae8..c238bb7 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -116,6 +116,10 @@ static void scfg_dns_rcon_cb(struct dns_async *dns)
scfg_dns_cb(dns, SCFG_KEY_RCON);
}
+/*
+ * FIXME: this is brittle, the dns request has already been triggered,
+ * can't just cancel on error.
+ */
static bool handle_dns(struct server_config *scfg, enum scfg_keys type,
struct cfg_value *value,
notification_cb_t notification_cb)
@@ -155,7 +159,7 @@ static bool handle_dns(struct server_config *scfg, enum scfg_keys type,
return false;
}
- if (!!notification_cb) {
+ if (!notification_cb) {
error("async DNS lookup received but not requested");
xfree(dns);
return false;
@@ -263,12 +267,12 @@ bool scfg_validate(struct server_config *scfg)
error("%s: systemd start/stop method missing "
"systemd service", scfg->filename);
return false;
- } else {
- if (scfg->systemd_service || scfg->systemd_obj) {
- error("%s: systemd service set but not used",
- scfg->filename);
- return false;
- }
+ }
+ } else {
+ if (scfg->systemd_service || scfg->systemd_obj) {
+ error("%s: systemd service set but not used",
+ scfg->filename);
+ return false;
}
}
@@ -313,7 +317,7 @@ bool scfg_validate(struct server_config *scfg)
break;
case SERVER_TYPE_PROXY:
- if (scfg->announce_port == 0) {
+ if (scfg->announce_port != 0) {
error("%s: can't set announce port for proxy server",
scfg->filename);
return false;
@@ -581,11 +585,14 @@ bool scfg_init(struct server_config *scfg, const char *filename)
if (filename) {
scfg->filename = xstrdup(filename);
+
if (!scfg->filename) {
error("strdup: %m");
return false;
}
- }
+ } else
+ scfg->filename = NULL;
+
scfg->type = SERVER_TYPE_UNDEFINED;
scfg->pretty_name = NULL;
scfg->announce_port = 0;
@@ -1042,9 +1049,10 @@ bool config_parse_line(const char *filename, char **buf,
/* sanity check */
if ((rvalue->type != kvmap[i].value_type) &&
- ((kvmap[i].value_type != CFG_VAL_TYPE_ASYNC_ADDRS) &&
- (rvalue->type != CFG_VAL_TYPE_ADDRS))) {
- error("rvalue->type != kvmap->type");
+ ((kvmap[i].value_type != CFG_VAL_TYPE_ADDRS) &&
+ (rvalue->type != CFG_VAL_TYPE_ASYNC_ADDRS))) {
+ error("rvalue->type != kvmap->type (%i %i)",
+ rvalue->type, kvmap[i].value_type);
goto error;
}