summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/config-parser.c11
-rw-r--r--shared/server-config-options.h84
-rw-r--r--shared/utils.h3
3 files changed, 94 insertions, 4 deletions
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 9c89cf2..1c9979e 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -60,7 +60,8 @@ get_line(char **pos)
}
static bool
-dnslookup(const char *name, uint16_t port, struct cfg_value *rvalue, bool async)
+dnslookup(const char *name, uint16_t port, struct cfg_value *rvalue,
+ unsigned *naddrs, bool async)
{
struct sockaddr_in *in4;
struct sockaddr_in6 *in6;
@@ -132,15 +133,17 @@ dnslookup(const char *name, uint16_t port, struct cfg_value *rvalue, bool async)
case AF_INET:
in4 = (struct sockaddr_in *)ai->ai_addr;
saddr_set_ipv4(saddr, in4->sin_addr.s_addr, in4->sin_port);
- error("addrstr: %s", saddr->addrstr);
+ debug(DBG_CFG, "addrstr: %s", saddr->addrstr);
list_add(&saddr->list, &rvalue->saddrs);
+ (*naddrs)++;
break;
case AF_INET6:
in6 = (struct sockaddr_in6 *)ai->ai_addr;
saddr_set_ipv6(saddr, &in6->sin6_addr, in6->sin6_port);
- error("addrstr: %s", saddr->addrstr);
+ debug(DBG_CFG, "addrstr: %s", saddr->addrstr);
list_add(&saddr->list, &rvalue->saddrs);
+ (*naddrs)++;
break;
default:
@@ -249,7 +252,7 @@ strtosockaddrs(const char *str, struct cfg_value *rvalue, bool async)
xfree(saddr);
debug(DBG_CFG, "maybe got a hostname:port (%s:%" PRIu16 ")", str, port);
- if (!dnslookup(str, port, rvalue, async))
+ if (!dnslookup(str, port, rvalue, &naddrs, async))
goto error;
} else if (strtou16_strict(tmp, &port) == 0) {
diff --git a/shared/server-config-options.h b/shared/server-config-options.h
new file mode 100644
index 0000000..acedb7a
--- /dev/null
+++ b/shared/server-config-options.h
@@ -0,0 +1,84 @@
+#ifndef fooserverconfigoptionshfoo
+#define fooserverconfigoptionshfoo
+
+#define SERVER_CFG_HEADER "server"
+
+enum scfg_keys {
+ SCFG_KEY_INVALID = 0,
+ SCFG_KEY_TYPE,
+ SCFG_KEY_NAME,
+ SCFG_KEY_PORT,
+ SCFG_KEY_LOCAL,
+ SCFG_KEY_REMOTE,
+ SCFG_KEY_IDLE_TIMEOUT,
+ SCFG_KEY_STOP_METHOD,
+ SCFG_KEY_START_METHOD,
+ SCFG_KEY_STOP_EXEC,
+ SCFG_KEY_START_EXEC,
+ SCFG_KEY_RCON,
+ SCFG_KEY_RCON_PASSWORD,
+ SCFG_KEY_SYSTEMD_SERVICE,
+};
+
+struct cfg_key_value_map scfg_key_map[] = {
+ {
+ .key_name = "type",
+ .key_value = SCFG_KEY_TYPE,
+ .value_type = CFG_VAL_TYPE_STRING,
+ }, {
+ .key_name = "name",
+ .key_value = SCFG_KEY_NAME,
+ .value_type = CFG_VAL_TYPE_STRING,
+ }, {
+ .key_name = "port",
+ .key_value = SCFG_KEY_PORT,
+ .value_type = CFG_VAL_TYPE_UINT16,
+ }, {
+ .key_name = "local",
+ .key_value = SCFG_KEY_LOCAL,
+ .value_type = CFG_VAL_TYPE_ASYNC_ADDRS,
+ }, {
+ .key_name = "remote",
+ .key_value = SCFG_KEY_REMOTE,
+ .value_type = CFG_VAL_TYPE_ASYNC_ADDRS,
+ }, {
+ .key_name = "idle_timeout",
+ .key_value = SCFG_KEY_IDLE_TIMEOUT,
+ .value_type = CFG_VAL_TYPE_UINT16,
+ }, {
+ .key_name = "stop_method",
+ .key_value = SCFG_KEY_STOP_METHOD,
+ .value_type = CFG_VAL_TYPE_STRING,
+ }, {
+ .key_name = "start_method",
+ .key_value = SCFG_KEY_START_METHOD,
+ .value_type = CFG_VAL_TYPE_STRING,
+ }, {
+ .key_name = "stop_exec",
+ .key_value = SCFG_KEY_STOP_EXEC,
+ .value_type = CFG_VAL_TYPE_STRING,
+ }, {
+ .key_name = "start_exec",
+ .key_value = SCFG_KEY_START_EXEC,
+ .value_type = CFG_VAL_TYPE_STRING,
+ }, {
+ .key_name = "rcon",
+ .key_value = SCFG_KEY_RCON,
+ .value_type = CFG_VAL_TYPE_ASYNC_ADDRS,
+ }, {
+ .key_name = "rcon_password",
+ .key_value = SCFG_KEY_RCON_PASSWORD,
+ .value_type = CFG_VAL_TYPE_STRING,
+ }, {
+ .key_name = "systemd_service",
+ .key_value = SCFG_KEY_SYSTEMD_SERVICE,
+ .value_type = CFG_VAL_TYPE_STRING,
+ }, {
+ .key_name = NULL,
+ .key_value = SCFG_KEY_INVALID,
+ .value_type = CFG_VAL_TYPE_INVALID,
+ }
+};
+
+#endif
+
diff --git a/shared/utils.h b/shared/utils.h
index df728b2..3ad603b 100644
--- a/shared/utils.h
+++ b/shared/utils.h
@@ -6,6 +6,9 @@
#include <stdbool.h>
#include <stdlib.h>
#include <linux/if_packet.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
extern unsigned debug_mask;