From c3c566aaf146b292ad4638319a4750f9f843d65a Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 24 Jun 2020 00:29:42 +0200 Subject: Make async dns an explicit argument --- shared/config-parser.c | 30 ++++++++++++------------------ shared/config-parser.h | 2 +- shared/server-config-options.h | 6 +++--- 3 files changed, 16 insertions(+), 22 deletions(-) (limited to 'shared') diff --git a/shared/config-parser.c b/shared/config-parser.c index 8dedbe5..e2ff413 100644 --- a/shared/config-parser.c +++ b/shared/config-parser.c @@ -320,7 +320,8 @@ error: bool config_parse_line(const char *filename, char **buf, struct cfg_key_value_map *kvmap, int *rkey, - const char **rkeyname, struct cfg_value *rvalue) + const char **rkeyname, struct cfg_value *rvalue, + bool async_dns) { char *line, *tmp, *key; int i; @@ -385,23 +386,12 @@ config_parse_line(const char *filename, char **buf, break; } - case CFG_VAL_TYPE_ADDRS: - if (!strtosockaddrs(tmp, rvalue, false)) - goto error; - - if (rvalue->type != CFG_VAL_TYPE_ADDRS) { - error("invalid type returned from strtosockaddrs"); - goto error; - } - - if (list_empty(&rvalue->saddrs)) { - error("empty address list"); - goto error; - } - break; - case CFG_VAL_TYPE_ASYNC_ADDRS: - if (!strtosockaddrs(tmp, rvalue, true)) + error("CFG_VAL_TYPE_ASYNC_ADDRS is a return value"); + /* Fall through */ + + case CFG_VAL_TYPE_ADDRS: + if (!strtosockaddrs(tmp, rvalue, async_dns)) goto error; switch (rvalue->type) { @@ -413,6 +403,11 @@ config_parse_line(const char *filename, char **buf, break; case CFG_VAL_TYPE_ASYNC_ADDRS: + if (!async_dns) { + error("unexpected async dns result"); + goto error; + } + if (!rvalue->dns_async) { error("dns_async not set"); goto error; @@ -423,7 +418,6 @@ config_parse_line(const char *filename, char **buf, error("invalid type returned from strtosockaddrs"); goto error; } - break; case CFG_VAL_TYPE_BOOL: diff --git a/shared/config-parser.h b/shared/config-parser.h index 4b2103f..e371dec 100644 --- a/shared/config-parser.h +++ b/shared/config-parser.h @@ -51,7 +51,7 @@ struct cfg_value { bool config_parse_line(const char *filename, char **buf, struct cfg_key_value_map *kvmap, int *rkey, const char **rkeyname, - struct cfg_value *rvalue); + struct cfg_value *rvalue, bool async_dns); bool config_parse_header(const char *title, char **buf); diff --git a/shared/server-config-options.h b/shared/server-config-options.h index acedb7a..5aee734 100644 --- a/shared/server-config-options.h +++ b/shared/server-config-options.h @@ -36,11 +36,11 @@ struct cfg_key_value_map scfg_key_map[] = { }, { .key_name = "local", .key_value = SCFG_KEY_LOCAL, - .value_type = CFG_VAL_TYPE_ASYNC_ADDRS, + .value_type = CFG_VAL_TYPE_ADDRS, }, { .key_name = "remote", .key_value = SCFG_KEY_REMOTE, - .value_type = CFG_VAL_TYPE_ASYNC_ADDRS, + .value_type = CFG_VAL_TYPE_ADDRS, }, { .key_name = "idle_timeout", .key_value = SCFG_KEY_IDLE_TIMEOUT, @@ -64,7 +64,7 @@ struct cfg_key_value_map scfg_key_map[] = { }, { .key_name = "rcon", .key_value = SCFG_KEY_RCON, - .value_type = CFG_VAL_TYPE_ASYNC_ADDRS, + .value_type = CFG_VAL_TYPE_ADDRS, }, { .key_name = "rcon_password", .key_value = SCFG_KEY_RCON_PASSWORD, -- cgit v1.2.3