summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-24 00:29:42 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-24 00:29:42 +0200
commitc3c566aaf146b292ad4638319a4750f9f843d65a (patch)
treee303645b14f969363857e777329ca8f03e075d53
parent3afaf3d8f7617beed427c96e544ab177fabadaa4 (diff)
Make async dns an explicit argument
-rw-r--r--minecctl/minecctl.c2
-rw-r--r--minecproxy/main.c2
-rw-r--r--minecproxy/server-config.c2
-rw-r--r--shared/config-parser.c30
-rw-r--r--shared/config-parser.h2
-rw-r--r--shared/server-config-options.h6
6 files changed, 19 insertions, 25 deletions
diff --git a/minecctl/minecctl.c b/minecctl/minecctl.c
index 1dc2a85..acee3b1 100644
--- a/minecctl/minecctl.c
+++ b/minecctl/minecctl.c
@@ -235,7 +235,7 @@ parse_config(char *buf, const char *filename,
struct cfg_value value;
if (!config_parse_line(filename, &buf, scfg_key_map,
- &key, &keyname, &value))
+ &key, &keyname, &value, false))
break;
switch (key) {
diff --git a/minecproxy/main.c b/minecproxy/main.c
index 3c996ad..f83b956 100644
--- a/minecproxy/main.c
+++ b/minecproxy/main.c
@@ -307,7 +307,7 @@ cfg_read()
struct cfg_value value;
if (!config_parse_line(path, &pos, mcfg_key_map,
- &key, &keyname, &value))
+ &key, &keyname, &value, false))
break;
if (key == MCFG_KEY_INVALID)
diff --git a/minecproxy/server-config.c b/minecproxy/server-config.c
index e7cc422..c388eb2 100644
--- a/minecproxy/server-config.c
+++ b/minecproxy/server-config.c
@@ -165,7 +165,7 @@ scfg_parse(struct server *server)
struct cfg_value value;
if (!config_parse_line(server->name, &pos, scfg_key_map,
- &key, &keyname, &value))
+ &key, &keyname, &value, true))
break;
if (key == SCFG_KEY_INVALID)
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,