summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cfgdir.c114
-rw-r--r--proxy.c42
-rw-r--r--proxy.h4
-rw-r--r--server.c422
-rw-r--r--server.h34
5 files changed, 310 insertions, 306 deletions
diff --git a/cfgdir.c b/cfgdir.c
index 2e73719..494ff81 100644
--- a/cfgdir.c
+++ b/cfgdir.c
@@ -19,7 +19,7 @@
static void
scfg_dns_cb(struct dns_async *dns, bool (*server_cb)(struct cfg *, struct server *, struct saddr *))
{
- struct server *scfg;
+ struct server *server;
struct cfg *cfg;
struct sockaddr_in *in4;
struct sockaddr_in6 *in6;
@@ -32,11 +32,11 @@ scfg_dns_cb(struct dns_async *dns, bool (*server_cb)(struct cfg *, struct server
return;
}
- scfg = dns->priv;
- cfg = scfg->cfg;
+ server = dns->priv;
+ cfg = server->cfg;
- debug(DBG_DNS, "called, dns: %p, name: %s, scfg: %p, scfg->name: %s",
- dns, dns->name, scfg, scfg->name);
+ debug(DBG_DNS, "called, dns: %p, name: %s, server: %p, server->name: %s",
+ dns, dns->name, server, server->name);
r = gai_error(&dns->gcb);
if (r == EAI_INPROGRESS) {
@@ -65,13 +65,13 @@ scfg_dns_cb(struct dns_async *dns, bool (*server_cb)(struct cfg *, struct server
case AF_INET:
in4 = (struct sockaddr_in *)ai->ai_addr;
saddr_set_ipv4(saddr, in4->sin_addr.s_addr, in4->sin_port);
- server_cb(cfg, scfg, saddr);
+ server_cb(cfg, server, saddr);
break;
case AF_INET6:
in6 = (struct sockaddr_in6 *)ai->ai_addr;
saddr_set_ipv6(saddr, &in6->sin6_addr, in6->sin6_port);
- server_cb(cfg, scfg, saddr);
+ server_cb(cfg, server, saddr);
break;
default:
@@ -86,8 +86,8 @@ out:
freeaddrinfo(results);
list_del(&dns->list);
xfree(dns);
- uring_task_put(cfg, &scfg->task);
- server_commit(cfg, scfg);
+ uring_task_put(cfg, &server->task);
+ server_commit(cfg, server);
}
static void
@@ -186,7 +186,7 @@ struct cfg_key_value_map scfg_key_map[] = {
};
static bool
-handle_dns(struct cfg *cfg, struct server *scfg, const char *type,
+handle_dns(struct cfg *cfg, struct server *server, const char *type,
struct cfg_value *value, dns_cb_t *async_cb,
bool (*sync_cb)(struct cfg *, struct server *, struct saddr *))
{
@@ -199,7 +199,7 @@ handle_dns(struct cfg *cfg, struct server *scfg, const char *type,
list_for_each_entry_safe(saddr, tmp, &value->saddrs, list) {
list_del(&saddr->list);
- sync_cb(cfg, scfg, saddr);
+ sync_cb(cfg, server, saddr);
}
return true;
@@ -209,9 +209,9 @@ handle_dns(struct cfg *cfg, struct server *scfg, const char *type,
dns = value->dns_async;
dns->cb = async_cb;
- dns->priv = scfg;
- list_add(&dns->list, &scfg->dnslookups);
- uring_task_get(cfg, &scfg->task);
+ dns->priv = server;
+ list_add(&dns->list, &server->dnslookups);
+ uring_task_get(cfg, &server->task);
return true;
default:
@@ -220,11 +220,11 @@ handle_dns(struct cfg *cfg, struct server *scfg, const char *type,
}
static void
-scfg_parse(struct cfg *cfg, struct server *scfg)
+scfg_parse(struct cfg *cfg, struct server *server)
{
- char *pos = &scfg->tbuf.buf[0];
+ char *pos = &server->tbuf.buf[0];
- if (!config_parse_header(cfg, scfg->name, "server", &pos))
+ if (!config_parse_header(cfg, server->name, "server", &pos))
return;
while (true) {
@@ -232,100 +232,100 @@ scfg_parse(struct cfg *cfg, struct server *scfg)
const char *keyname;
struct cfg_value value;
- if (!config_parse_line(cfg, scfg->name, &pos, scfg_key_map,
+ if (!config_parse_line(cfg, server->name, &pos, scfg_key_map,
&key, &keyname, &value))
break;
if (key == SCFG_KEY_INVALID)
break;
- debug(DBG_CFG, "%s: key %s", scfg->name, keyname);
+ debug(DBG_CFG, "%s: key %s", server->name, keyname);
switch (key) {
case SCFG_KEY_TYPE:
if (!strcmp(value.str, "proxy")) {
- if (!server_set_type(cfg, scfg, SERVER_TYPE_PROXY))
+ if (!server_set_type(cfg, server, SERVER_TYPE_PROXY))
return;
} else if (!strcmp(value.str, "announce")) {
- if (!server_set_type(cfg, scfg, SERVER_TYPE_ANNOUNCE))
+ if (!server_set_type(cfg, server, SERVER_TYPE_ANNOUNCE))
return;
}
break;
case SCFG_KEY_NAME:
- if (!server_set_pretty_name(cfg, scfg, value.str))
+ if (!server_set_pretty_name(cfg, server, value.str))
return;
break;
case SCFG_KEY_PORT:
- if (!server_set_port(cfg, scfg, value.uint16))
+ if (!server_set_port(cfg, server, value.uint16))
return;
break;
case SCFG_KEY_LOCAL:
- if (!handle_dns(cfg, scfg, "local", &value,
+ if (!handle_dns(cfg, server, "local", &value,
scfg_local_dns_cb, server_add_local))
return;
break;
case SCFG_KEY_REMOTE:
- if (!handle_dns(cfg, scfg, "remote", &value,
+ if (!handle_dns(cfg, server, "remote", &value,
scfg_remote_dns_cb, server_add_remote))
return;
break;
case SCFG_KEY_IDLE_TIMEOUT:
- if (!server_set_idle_timeout(cfg, scfg, value.uint16))
+ if (!server_set_idle_timeout(cfg, server, value.uint16))
return;
break;
case SCFG_KEY_STOP_METHOD:
if (!strcmp(value.str, "exec")) {
- if (server_set_stop_method(cfg, scfg, SERVER_STOP_METHOD_EXEC))
+ if (server_set_stop_method(cfg, server, SERVER_STOP_METHOD_EXEC))
break;
} else if (!strcmp(value.str, "rcon")) {
- if (server_set_stop_method(cfg, scfg, SERVER_STOP_METHOD_RCON))
+ if (server_set_stop_method(cfg, server, SERVER_STOP_METHOD_RCON))
break;
} else if (!strcmp(value.str, "systemd")) {
- if (server_set_stop_method(cfg, scfg, SERVER_STOP_METHOD_SYSTEMD))
+ if (server_set_stop_method(cfg, server, SERVER_STOP_METHOD_SYSTEMD))
break;
}
return;
case SCFG_KEY_START_METHOD:
if (!strcmp(value.str, "exec")) {
- if (server_set_start_method(cfg, scfg, SERVER_START_METHOD_EXEC))
+ if (server_set_start_method(cfg, server, SERVER_START_METHOD_EXEC))
break;
} else if (!strcmp(value.str, "systemd")) {
- if (server_set_start_method(cfg, scfg, SERVER_START_METHOD_SYSTEMD))
+ if (server_set_start_method(cfg, server, SERVER_START_METHOD_SYSTEMD))
break;
}
return;
case SCFG_KEY_STOP_EXEC:
- if (!server_set_stop_exec(cfg, scfg, value.str))
+ if (!server_set_stop_exec(cfg, server, value.str))
return;
break;
case SCFG_KEY_START_EXEC:
- if (!server_set_start_exec(cfg, scfg, value.str))
+ if (!server_set_start_exec(cfg, server, value.str))
return;
break;
case SCFG_KEY_RCON:
- if (!handle_dns(cfg, scfg, "rcon", &value,
+ if (!handle_dns(cfg, server, "rcon", &value,
scfg_rcon_dns_cb, server_add_rcon))
return;
break;
case SCFG_KEY_RCON_PASSWORD:
- if (!server_set_rcon_password(cfg, scfg, value.str))
+ if (!server_set_rcon_password(cfg, server, value.str))
return;
break;
case SCFG_KEY_SYSTEMD_SERVICE:
- if (!server_set_systemd_service(cfg, scfg, value.str))
+ if (!server_set_systemd_service(cfg, server, value.str))
return;
break;
@@ -339,38 +339,38 @@ scfg_parse(struct cfg *cfg, struct server *scfg)
static void
scfg_read_cb(struct cfg *cfg, struct uring_task *task, int res)
{
- struct server *scfg = container_of(task, struct server, task);
+ struct server *server = container_of(task, struct server, task);
assert_task_alive(DBG_CFG, task);
if (res <= 0) {
error("error reading config file for %s: %s",
- scfg->name, strerror(-res));
- server_delete(cfg, scfg);
+ server->name, strerror(-res));
+ server_delete(cfg, server);
}
- debug(DBG_CFG, "%s: parsing cfg (%i bytes)", scfg->name, res);
- uring_task_close_fd(cfg, &scfg->task);
- scfg_parse(cfg, scfg);
- server_commit(cfg, scfg);
+ debug(DBG_CFG, "%s: parsing cfg (%i bytes)", server->name, res);
+ uring_task_close_fd(cfg, &server->task);
+ scfg_parse(cfg, server);
+ server_commit(cfg, server);
}
static void
scfg_open_cb(struct cfg *cfg, struct uring_task *task, int res)
{
- struct server *scfg = container_of(task, struct server, task);
+ struct server *server = container_of(task, struct server, task);
assert_task_alive(DBG_CFG, task);
if (res < 0) {
- error("open(%s) failed: %s", scfg->name, strerror(-res));
- server_delete(cfg, scfg);
+ error("open(%s) failed: %s", server->name, strerror(-res));
+ server_delete(cfg, server);
return;
}
- debug(DBG_CFG, "reading server cfg %s (fd %i)", scfg->name, res);
- uring_task_set_fd(&scfg->task, res);
- uring_tbuf_read_until_eof(cfg, &scfg->task, scfg_read_cb);
+ debug(DBG_CFG, "reading server cfg %s (fd %i)", server->name, res);
+ uring_task_set_fd(&server->task, res);
+ uring_tbuf_read_until_eof(cfg, &server->task, scfg_read_cb);
}
static bool
@@ -457,7 +457,7 @@ inotify_cb(struct cfg *cfg, struct uring_task *task, int res)
struct inotify_ev *iev = container_of(task, struct inotify_ev, task);
const struct inotify_event *event;
char *ptr;
- struct server *scfg;
+ struct server *server;
assert_task_alive(DBG_CFG, task);
@@ -486,9 +486,9 @@ inotify_cb(struct cfg *cfg, struct uring_task *task, int res)
if (event->mask & (IN_MOVED_FROM | IN_DELETE))
server_delete_by_name(cfg, event->name);
else if (event->mask & (IN_MOVED_TO | IN_CREATE | IN_CLOSE_WRITE)) {
- scfg = server_new(cfg, event->name);
- verbose("New server config file detected: %s", scfg->name);
- uring_openat(cfg, &scfg->task, scfg->name, scfg_open_cb);
+ server = server_new(cfg, event->name);
+ verbose("New server config file detected: %s", server->name);
+ uring_openat(cfg, &server->task, server->name, scfg_open_cb);
} else
error("inotify: unknown event: 0x%08x", event->mask);
}
@@ -523,7 +523,7 @@ cfgdir_init(struct cfg *cfg)
struct inotify_ev *iev;
DIR *dir;
struct dirent *dent;
- struct server *scfg;
+ struct server *server;
iev = zmalloc(sizeof(*iev));
if (!iev)
@@ -557,9 +557,9 @@ cfgdir_init(struct cfg *cfg)
if (!scfg_valid_filename(dent->d_name))
continue;
- scfg = server_new(cfg, dent->d_name);
- if (scfg)
- uring_openat(cfg, &scfg->task, scfg->name, scfg_open_cb);
+ server = server_new(cfg, dent->d_name);
+ if (server)
+ uring_openat(cfg, &server->task, server->name, scfg_open_cb);
}
closedir(dir);
diff --git a/proxy.c b/proxy.c
index 6ced85b..a629d7c 100644
--- a/proxy.c
+++ b/proxy.c
@@ -68,7 +68,7 @@ proxy_free(struct uring_task *task)
char duration[100];
debug(DBG_PROXY, "server: %s, src: %s, dst: %s",
- proxy->scfg->name,
+ proxy->server->name,
proxy->client_conn.remote.addrstr,
proxy->server_conn.remote.addrstr);
@@ -79,7 +79,7 @@ proxy_free(struct uring_task *task)
info("%s: proxy connection %s -> %s closed "
"(CtS: %s, StC: %s), duration %s",
- proxy->scfg->name,
+ proxy->server->name,
proxy->client_conn.remote.addrstr,
proxy->server_conn.remote.addrstr,
cts, stc, duration);
@@ -94,7 +94,7 @@ proxy_client_free(struct uring_task *task)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, clienttask);
- debug(DBG_PROXY, "%s: client connection closed", proxy->scfg->name);
+ debug(DBG_PROXY, "%s: client connection closed", proxy->server->name);
}
static void
@@ -102,13 +102,13 @@ proxy_server_free(struct uring_task *task)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, servertask);
- debug(DBG_PROXY, "%s: server connection closed", proxy->scfg->name);
+ debug(DBG_PROXY, "%s: server connection closed", proxy->server->name);
}
void
proxy_delete(struct cfg *cfg, struct server_proxy *proxy)
{
- debug(DBG_PROXY, "%s: shutting down proxy %p", proxy->scfg->name, proxy);
+ debug(DBG_PROXY, "%s: shutting down proxy %p", proxy->server->name, proxy);
uring_task_destroy(cfg, &proxy->servertask);
uring_task_destroy(cfg, &proxy->clienttask);
@@ -125,7 +125,7 @@ proxy_client_data_out(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_PROXY, task);
if (res <= 0) {
- debug(DBG_PROXY, "%s: result was %i", proxy->scfg->name, res);
+ debug(DBG_PROXY, "%s: result was %i", proxy->server->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -144,7 +144,7 @@ proxy_client_data_in(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_PROXY, task);
if (res <= 0) {
- debug(DBG_PROXY, "%s: result was %i", proxy->scfg->name, res);
+ debug(DBG_PROXY, "%s: result was %i", proxy->server->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -154,7 +154,8 @@ proxy_client_data_in(struct cfg *cfg, struct uring_task *task, int res)
uring_tbuf_write(cfg, task, proxy_client_data_out);
}
-static void proxy_server_data_in(struct cfg *cfg, struct uring_task *task, int res);
+static void proxy_server_data_in(struct cfg *cfg, struct uring_task *task,
+ int res);
static void
proxy_server_data_out(struct cfg *cfg, struct uring_task *task, int res)
@@ -164,7 +165,7 @@ proxy_server_data_out(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_PROXY, task);
if (res <= 0) {
- debug(DBG_PROXY, "%s: result was %i", proxy->scfg->name, res);
+ debug(DBG_PROXY, "%s: result was %i", proxy->server->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -183,7 +184,7 @@ proxy_server_data_in(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_PROXY, task);
if (res <= 0) {
- debug(DBG_PROXY, "%s: result was %i", proxy->scfg->name, res);
+ debug(DBG_PROXY, "%s: result was %i", proxy->server->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -203,14 +204,14 @@ proxy_connected_cb(struct cfg *cfg, struct connection *conn, bool connected)
if (!connected) {
error("%s: proxy connection to remote server failed",
- proxy->scfg->name);
+ proxy->server->name);
proxy_delete(cfg, proxy);
return;
}
proxy->sfd = proxy->servertask.fd;
verbose("%s: proxy connection %s -> %s opened",
- proxy->scfg->name,
+ proxy->server->name,
proxy->client_conn.remote.addrstr,
proxy->server_conn.remote.addrstr);
proxy->begin = time(NULL);
@@ -220,7 +221,7 @@ proxy_connected_cb(struct cfg *cfg, struct connection *conn, bool connected)
}
struct server_proxy *
-proxy_new(struct cfg *cfg, struct server *scfg, struct saddr *client, int fd)
+proxy_new(struct cfg *cfg, struct server *server, struct saddr *client, int fd)
{
struct server_proxy *proxy;
@@ -232,21 +233,24 @@ proxy_new(struct cfg *cfg, struct server *scfg, struct saddr *client, int fd)
proxy->sfd = -1;
proxy->cfd = fd;
- proxy->scfg = scfg;
- uring_task_init(&proxy->task, "proxy", &scfg->task, proxy_free);
+ proxy->server = server;
+ uring_task_init(&proxy->task, "proxy", &server->task, proxy_free);
connection_set_local(cfg, &proxy->client_conn, fd);
connection_set_remote(cfg, &proxy->client_conn, client);
- uring_task_init(&proxy->clienttask, "proxy_client", &proxy->task, proxy_client_free);
+ uring_task_init(&proxy->clienttask, "proxy_client", &proxy->task,
+ proxy_client_free);
uring_task_set_buf(&proxy->clienttask, &proxy->clientbuf);
uring_task_set_fd(&proxy->clienttask, fd);
- uring_task_init(&proxy->servertask, "proxy_server", &proxy->task, proxy_server_free);
+ uring_task_init(&proxy->servertask, "proxy_server", &proxy->task,
+ proxy_server_free);
uring_task_set_buf(&proxy->servertask, &proxy->serverbuf);
- list_add(&proxy->list, &scfg->proxys);
- connect_any(cfg, &proxy->servertask, &scfg->remotes, &proxy->server_conn, proxy_connected_cb);
+ list_add(&proxy->list, &server->proxys);
+ connect_any(cfg, &proxy->servertask, &server->remotes,
+ &proxy->server_conn, proxy_connected_cb);
return proxy;
}
diff --git a/proxy.h b/proxy.h
index 8812fa6..d0533e0 100644
--- a/proxy.h
+++ b/proxy.h
@@ -17,7 +17,7 @@ struct server_proxy {
time_t begin;
unsigned next_remote;
struct uring_task task;
- struct server *scfg;
+ struct server *server;
struct list_head list;
};
@@ -25,6 +25,6 @@ void proxy_refdump(struct server_proxy *proxy);
void proxy_delete(struct cfg *cfg, struct server_proxy *proxy);
-struct server_proxy *proxy_new(struct cfg *cfg, struct server *scfg, struct saddr *client, int fd);
+struct server_proxy *proxy_new(struct cfg *cfg, struct server *server, struct saddr *client, int fd);
#endif
diff --git a/server.c b/server.c
index ea2d370..3f7a7bf 100644
--- a/server.c
+++ b/server.c
@@ -32,9 +32,9 @@ struct server_local {
};
static bool
-set_property(struct cfg *cfg, struct server *scfg, char **property, const char *value)
+set_property(struct cfg *cfg, struct server *server, char **property, const char *value)
{
- if (!cfg || !scfg || empty_str(value) || *property)
+ if (!cfg || !server || empty_str(value) || *property)
return false;
*property = xstrdup(value);
@@ -64,22 +64,22 @@ server_refdump(struct server *server)
static void
server_free(struct uring_task *task)
{
- struct server *scfg = container_of(task, struct server, task);
-
- debug(DBG_SRV, "freeing server %s (%p)", scfg->name, scfg);
- list_del(&scfg->list);
- xfree(scfg->pretty_name);
- xfree(scfg->start_exec);
- xfree(scfg->stop_exec);
- xfree(scfg->systemd_service);
- xfree(scfg->systemd_obj);
- xfree(scfg->rcon_password);
- xfree(scfg->name);
- xfree(scfg);
+ struct server *server = container_of(task, struct server, task);
+
+ debug(DBG_SRV, "freeing server %s (%p)", server->name, server);
+ list_del(&server->list);
+ xfree(server->pretty_name);
+ xfree(server->start_exec);
+ xfree(server->stop_exec);
+ xfree(server->systemd_service);
+ xfree(server->systemd_obj);
+ xfree(server->rcon_password);
+ xfree(server->name);
+ xfree(server);
}
void
-server_delete(struct cfg *cfg, struct server *scfg)
+server_delete(struct cfg *cfg, struct server *server)
{
struct server_local *local, *ltmp;
struct server_proxy *proxy, *ptmp;
@@ -88,60 +88,60 @@ server_delete(struct cfg *cfg, struct server *scfg)
struct saddr *tmp;
struct dns_async *dns, *dtmp;
- verbose("Removing server %s", scfg->name);
+ verbose("Removing server %s", server->name);
- idle_delete(cfg, scfg);
- rcon_delete(cfg, scfg);
+ idle_delete(cfg, server);
+ rcon_delete(cfg, server);
- list_for_each_entry_safe(local, ltmp, &scfg->locals, list)
+ list_for_each_entry_safe(local, ltmp, &server->locals, list)
uring_task_destroy(cfg, &local->task);
- list_for_each_entry_safe(proxy, ptmp, &scfg->proxys, list)
+ list_for_each_entry_safe(proxy, ptmp, &server->proxys, list)
proxy_delete(cfg, proxy);
- list_for_each_entry_safe(rcon, tmp, &scfg->rcons, list) {
+ list_for_each_entry_safe(rcon, tmp, &server->rcons, list) {
list_del(&rcon->list);
xfree(rcon);
}
- list_for_each_entry_safe(remote, tmp, &scfg->remotes, list) {
+ list_for_each_entry_safe(remote, tmp, &server->remotes, list) {
list_del(&remote->list);
xfree(remote);
}
- list_for_each_entry_safe(dns, dtmp, &scfg->dnslookups, list)
+ list_for_each_entry_safe(dns, dtmp, &server->dnslookups, list)
gai_cancel(&dns->gcb);
- uring_poll_cancel(cfg, &scfg->exec_task);
- uring_task_put(cfg, &scfg->exec_task);
- uring_task_destroy(cfg, &scfg->task);
+ uring_poll_cancel(cfg, &server->exec_task);
+ uring_task_put(cfg, &server->exec_task);
+ uring_task_destroy(cfg, &server->task);
}
void
server_delete_by_name(struct cfg *cfg, const char *name)
{
- struct server *scfg;
+ struct server *server;
if (!cfg || empty_str(name))
return;
- list_for_each_entry(scfg, &cfg->servers, list) {
- if (!strcmp(scfg->name, name)) {
- server_delete(cfg, scfg);
+ list_for_each_entry(server, &cfg->servers, list) {
+ if (!strcmp(server->name, name)) {
+ server_delete(cfg, server);
return;
}
}
}
static void
-server_dump(struct server *scfg)
+server_dump(struct server *server)
{
struct server_local *local;
struct saddr *remote;
struct saddr *rcon;
- verbose("Server %s:", scfg->name);
- switch (scfg->type) {
+ verbose("Server %s:", server->name);
+ switch (server->type) {
case SERVER_TYPE_ANNOUNCE:
verbose(" * Type: announce");
break;
@@ -152,24 +152,24 @@ server_dump(struct server *scfg)
verbose(" * Type: unknown");
break;
}
- verbose(" * Name: %s", scfg->pretty_name ? scfg->pretty_name : "<undefined>");
- verbose(" * Announce port: %" PRIu16, scfg->announce_port);
+ verbose(" * Name: %s", server->pretty_name ? server->pretty_name : "<undefined>");
+ verbose(" * Announce port: %" PRIu16, server->announce_port);
- if (!list_empty(&scfg->locals)) {
+ if (!list_empty(&server->locals)) {
verbose(" * Local:");
- list_for_each_entry(local, &scfg->locals, list)
+ list_for_each_entry(local, &server->locals, list)
verbose(" * %s", local->local.addrstr);
}
- if (!list_empty(&scfg->remotes)) {
+ if (!list_empty(&server->remotes)) {
verbose(" * Remote:");
- list_for_each_entry(remote, &scfg->remotes, list)
+ list_for_each_entry(remote, &server->remotes, list)
verbose(" * %s", remote->addrstr);
}
- if (!list_empty(&scfg->rcons)) {
+ if (!list_empty(&server->rcons)) {
verbose(" * RCon:");
- list_for_each_entry(rcon, &scfg->rcons, list)
+ list_for_each_entry(rcon, &server->rcons, list)
verbose(" * %s", rcon->addrstr);
}
@@ -190,10 +190,10 @@ static void
server_local_accept(struct cfg *cfg, struct uring_task *task, int res)
{
struct server_local *local = container_of(task, struct server_local, task);
- struct server *scfg = container_of(task->parent, struct server, task);
+ struct server *server = container_of(task->parent, struct server, task);
struct server_proxy *proxy;
- debug(DBG_SRV, "task %p, res %i, scfg %s", task, res, scfg->name);
+ debug(DBG_SRV, "task %p, res %i, server %s", task, res, server->name);
assert_task_alive(DBG_SRV, task);
@@ -205,16 +205,16 @@ server_local_accept(struct cfg *cfg, struct uring_task *task, int res)
saddr_set_addrstr(&local->client);
verbose("%s: incoming proxy connection: %s -> %s",
- scfg->name, local->client.addrstr, local->local.addrstr);
+ server->name, local->client.addrstr, local->local.addrstr);
- if (list_empty(&scfg->remotes)) {
+ if (list_empty(&server->remotes)) {
/* This shouldn't be possible, checked before opening local */
- error("scfg->remotes empty!");
+ error("server->remotes empty!");
uring_close(cfg, &local->task, res);
goto out;
}
- proxy = proxy_new(cfg, scfg, &local->client, res);
+ proxy = proxy_new(cfg, server, &local->client, res);
if (!proxy)
uring_close(cfg, &local->task, res);
@@ -223,7 +223,7 @@ out:
}
static bool
-server_local_open(struct cfg *cfg, struct server *scfg, struct server_local *local)
+server_local_open(struct cfg *cfg, struct server *server, struct server_local *local)
{
int sfd;
int option;
@@ -279,7 +279,7 @@ error:
static void
server_exec_free(struct uring_task *task)
{
- //struct server *scfg = container_of(task, struct server, exec_task);
+ //struct server *server = container_of(task, struct server, exec_task);
debug(DBG_SRV, "called");
}
@@ -292,7 +292,7 @@ server_exec_free(struct uring_task *task)
static void
server_exec_done(struct cfg *cfg, struct uring_task *task, int res)
{
- struct server *scfg = container_of(task, struct server, exec_task);
+ struct server *server = container_of(task, struct server, exec_task);
int r;
siginfo_t info;
@@ -304,7 +304,7 @@ server_exec_done(struct cfg *cfg, struct uring_task *task, int res)
goto out;
}
- r = waitid(P_PIDFD, scfg->exec_task.fd, &info, WEXITED);
+ r = waitid(P_PIDFD, server->exec_task.fd, &info, WEXITED);
if (r < 0) {
error("waitid: %m");
goto out;
@@ -316,7 +316,7 @@ server_exec_done(struct cfg *cfg, struct uring_task *task, int res)
error("command failed: %i", info.si_status);
out:
- uring_task_close_fd(cfg, &scfg->exec_task);
+ uring_task_close_fd(cfg, &server->exec_task);
}
static int
@@ -333,16 +333,16 @@ server_exec_child(void *ptr)
#endif
static bool
-server_exec(struct cfg *cfg, struct server *scfg, const char *cmd)
+server_exec(struct cfg *cfg, struct server *server, const char *cmd)
{
char stack[4096]; /* Beautiful/horrible hack :) */
int pidfd;
int r;
- if (!cfg || !scfg || !cmd)
+ if (!cfg || !server || !cmd)
return false;
- if (scfg->exec_task.fd >= 0)
+ if (server->exec_task.fd >= 0)
return false;
r = clone(server_exec_child, stack + sizeof(stack),
@@ -353,22 +353,22 @@ server_exec(struct cfg *cfg, struct server *scfg, const char *cmd)
return false;
}
- uring_task_set_fd(&scfg->exec_task, pidfd);
- uring_poll(cfg, &scfg->exec_task, POLLIN, server_exec_done);
+ uring_task_set_fd(&server->exec_task, pidfd);
+ uring_poll(cfg, &server->exec_task, POLLIN, server_exec_done);
return true;
}
static bool
-server_check_running(struct cfg *cfg, struct server *scfg)
+server_check_running(struct cfg *cfg, struct server *server)
{
/* FIXME: other methods, rcon? */
- if (scfg->systemd_service) {
- verbose("%s: checking if systemd service is running", scfg->name);
- if (systemd_service_running(cfg, scfg)) {
- scfg->state = SERVER_STATE_RUNNING;
+ if (server->systemd_service) {
+ verbose("%s: checking if systemd service is running", server->name);
+ if (systemd_service_running(cfg, server)) {
+ server->state = SERVER_STATE_RUNNING;
return true;
} else {
- scfg->state = SERVER_STATE_STOPPED;
+ server->state = SERVER_STATE_STOPPED;
return false;
}
}
@@ -377,29 +377,29 @@ server_check_running(struct cfg *cfg, struct server *scfg)
}
bool
-server_start(struct cfg *cfg, struct server *scfg)
+server_start(struct cfg *cfg, struct server *server)
{
- if (!cfg || !scfg)
+ if (!cfg || !server)
return false;
- if (scfg->task.dead)
+ if (server->task.dead)
return false;
- switch (scfg->start_method) {
+ switch (server->start_method) {
case SERVER_START_METHOD_EXEC:
- verbose("Starting server %s via external cmd", scfg->name);
- return server_exec(cfg, scfg, scfg->start_exec);
+ verbose("Starting server %s via external cmd", server->name);
+ return server_exec(cfg, server, server->start_exec);
case SERVER_START_METHOD_SYSTEMD:
verbose("Starting server %s via systemd (%s)",
- scfg->name, scfg->systemd_service);
+ server->name, server->systemd_service);
- if (systemd_service_start(cfg, scfg)) {
- scfg->state = SERVER_STATE_RUNNING;
+ if (systemd_service_start(cfg, server)) {
+ server->state = SERVER_STATE_RUNNING;
return true;
} else
- return server_check_running(cfg, scfg);
+ return server_check_running(cfg, server);
case SERVER_START_METHOD_UNDEFINED:
default:
@@ -410,32 +410,32 @@ server_start(struct cfg *cfg, struct server *scfg)
}
bool
-server_stop(struct cfg *cfg, struct server *scfg)
+server_stop(struct cfg *cfg, struct server *server)
{
- if (!cfg || !scfg)
+ if (!cfg || !server)
return false;
- if (scfg->task.dead)
+ if (server->task.dead)
return false;
- switch (scfg->stop_method) {
+ switch (server->stop_method) {
case SERVER_STOP_METHOD_EXEC:
- verbose("Stopping server %s via external cmd", scfg->name);
- return server_exec(cfg, scfg, scfg->stop_exec);
+ verbose("Stopping server %s via external cmd", server->name);
+ return server_exec(cfg, server, server->stop_exec);
case SERVER_STOP_METHOD_SYSTEMD:
verbose("Stopping server %s via systemd (%s)",
- scfg->name, scfg->systemd_service);
- if (systemd_service_stop(cfg, scfg)) {
- scfg->state = SERVER_STATE_STOPPED;
+ server->name, server->systemd_service);
+ if (systemd_service_stop(cfg, server)) {
+ server->state = SERVER_STATE_STOPPED;
return true;
} else
- return server_check_running(cfg, scfg);
+ return server_check_running(cfg, server);
case SERVER_STOP_METHOD_RCON:
- verbose("Stopping server %s via rcon", scfg->name);
- rcon_init(cfg, scfg);
+ verbose("Stopping server %s via rcon", server->name);
+ rcon_init(cfg, server);
return true;
case SERVER_STOP_METHOD_UNDEFINED:
@@ -447,198 +447,198 @@ server_stop(struct cfg *cfg, struct server *scfg)
}
bool
-server_commit(struct cfg *cfg, struct server *scfg)
+server_commit(struct cfg *cfg, struct server *server)
{
struct server_local *local;
uint16_t port;
- if (!scfg || !scfg->name) {
+ if (!server || !server->name) {
error("called with invalid parameters");
return false;
}
- if (scfg->task.dead)
+ if (server->task.dead)
return false;
- if (scfg->state != SERVER_STATE_INIT) {
+ if (server->state != SERVER_STATE_INIT) {
error("called in wrong state");
return false;
}
- if (!list_empty(&scfg->proxys)) {
- error("%s: proxys not empty?", scfg->name);
+ if (!list_empty(&server->proxys)) {
+ error("%s: proxys not empty?", server->name);
return false;
}
- if (!list_empty(&scfg->dnslookups)) {
+ if (!list_empty(&server->dnslookups)) {
debug(DBG_SRV, "called with pending DNS requests");
return true;
}
- if (scfg->stop_method == SERVER_STOP_METHOD_RCON &&
- list_empty(&scfg->rcons)) {
+ if (server->stop_method == SERVER_STOP_METHOD_RCON &&
+ list_empty(&server->rcons)) {
error("%s: rcon stop method missing rcon address",
- scfg->name);
+ server->name);
return false;
}
- if (scfg->stop_method == SERVER_STOP_METHOD_RCON &&
- !scfg->rcon_password) {
+ if (server->stop_method == SERVER_STOP_METHOD_RCON &&
+ !server->rcon_password) {
error("%s: rcon stop method missing rcon password",
- scfg->name);
+ server->name);
return false;
}
- if ((scfg->start_method == SERVER_START_METHOD_SYSTEMD ||
- scfg->stop_method == SERVER_STOP_METHOD_SYSTEMD) &&
- !scfg->systemd_service) {
+ if ((server->start_method == SERVER_START_METHOD_SYSTEMD ||
+ server->stop_method == SERVER_STOP_METHOD_SYSTEMD) &&
+ !server->systemd_service) {
error("%s: systemd start/stop method missing systemd service",
- scfg->name);
+ server->name);
return false;
}
- if (scfg->systemd_service && !scfg->systemd_obj) {
- scfg->systemd_obj = systemd_service_object_path(cfg,
- scfg->systemd_service);
- if (!scfg->systemd_obj) {
+ if (server->systemd_service && !server->systemd_obj) {
+ server->systemd_obj = systemd_service_object_path(cfg,
+ server->systemd_service);
+ if (!server->systemd_obj) {
error("%s: failed to create systemd object path (%s)",
- scfg->name, scfg->systemd_service);
+ server->name, server->systemd_service);
return false;
}
}
- if (scfg->idle_timeout > 0 &&
- scfg->stop_method == SERVER_STOP_METHOD_UNDEFINED) {
- error("%s: idle_timeout set but missing stop method", scfg->name);
+ if (server->idle_timeout > 0 &&
+ server->stop_method == SERVER_STOP_METHOD_UNDEFINED) {
+ error("%s: idle_timeout set but missing stop method", server->name);
return false;
}
- switch (scfg->type) {
+ switch (server->type) {
case SERVER_TYPE_ANNOUNCE:
- if (scfg->announce_port < 1) {
- error("%s: missing announce port", scfg->name);
+ if (server->announce_port < 1) {
+ error("%s: missing announce port", server->name);
return false;
}
- if (scfg->start_method != SERVER_START_METHOD_UNDEFINED) {
- error("%s: can't set start_method for announce server", scfg->name);
+ if (server->start_method != SERVER_START_METHOD_UNDEFINED) {
+ error("%s: can't set start_method for announce server", server->name);
return false;
}
- if (!list_empty(&scfg->locals)) {
- error("%s: can't set local addresses for announce server", scfg->name);
+ if (!list_empty(&server->locals)) {
+ error("%s: can't set local addresses for announce server", server->name);
return false;
}
- if (!list_empty(&scfg->remotes)) {
- error("%s: can't set remote addresses for announce server", scfg->name);
+ if (!list_empty(&server->remotes)) {
+ error("%s: can't set remote addresses for announce server", server->name);
return false;
}
break;
case SERVER_TYPE_PROXY:
- if (scfg->announce_port >= 1) {
- error("%s: can't set announce port for proxy server", scfg->name);
+ if (server->announce_port >= 1) {
+ error("%s: can't set announce port for proxy server", server->name);
return false;
}
- if (list_empty(&scfg->locals)) {
- error("%s: missing local addresses for proxy server", scfg->name);
+ if (list_empty(&server->locals)) {
+ error("%s: missing local addresses for proxy server", server->name);
return false;
}
- if (list_empty(&scfg->remotes)) {
- error("%s: missing remote addresses for proxy server", scfg->name);
+ if (list_empty(&server->remotes)) {
+ error("%s: missing remote addresses for proxy server", server->name);
return false;
}
- list_for_each_entry(local, &scfg->locals, list) {
+ list_for_each_entry(local, &server->locals, list) {
port = saddr_port(&local->local);
if (port == 0) {
- error("%s: invalid local port", scfg->name);
+ error("%s: invalid local port", server->name);
return false;
}
- if (scfg->announce_port < 1)
- scfg->announce_port = port;
+ if (server->announce_port < 1)
+ server->announce_port = port;
- if (scfg->announce_port != port) {
- error("%s: multiple local ports", scfg->name);
+ if (server->announce_port != port) {
+ error("%s: multiple local ports", server->name);
return false;
}
}
- if (scfg->announce_port < 1) {
- error("%s: can't determine which port to announce", scfg->name);
+ if (server->announce_port < 1) {
+ error("%s: can't determine which port to announce", server->name);
return false;
}
break;
default:
- error("%s: can't determine server type", scfg->name);
+ error("%s: can't determine server type", server->name);
return false;
}
- if (!scfg->pretty_name) {
+ if (!server->pretty_name) {
char *suffix;
- suffix = strrchr(scfg->name, '.');
- if (!suffix || suffix == scfg->name) {
- error("invalid server name: %s", scfg->name);
+ suffix = strrchr(server->name, '.');
+ if (!suffix || suffix == server->name) {
+ error("invalid server name: %s", server->name);
return false;
}
- scfg->pretty_name = xstrndup(scfg->name, suffix - scfg->name);
- if (!scfg->pretty_name) {
- error("failed to create display name: %s", scfg->name);
+ server->pretty_name = xstrndup(server->name, suffix - server->name);
+ if (!server->pretty_name) {
+ error("failed to create display name: %s", server->name);
return false;
}
}
/* FIXME: config, dont reread config if server running, make sure fd is available before this is called */
- server_dump(scfg);
+ server_dump(server);
- list_for_each_entry(local, &scfg->locals, list) {
- server_local_open(cfg, scfg, local);
+ list_for_each_entry(local, &server->locals, list) {
+ server_local_open(cfg, server, local);
}
- idle_init(cfg, scfg);
- scfg->state = SERVER_STATE_CFG_OK;
+ idle_init(cfg, server);
+ server->state = SERVER_STATE_CFG_OK;
- server_check_running(cfg, scfg);
+ server_check_running(cfg, server);
debug(DBG_SRV, "success");
return true;
}
bool
-server_add_remote(struct cfg *cfg, struct server *scfg, struct saddr *remote)
+server_add_remote(struct cfg *cfg, struct server *server, struct saddr *remote)
{
- if (!scfg || !remote)
+ if (!server || !remote)
return false;
- if (scfg->task.dead)
+ if (server->task.dead)
return false;
debug(DBG_SRV, "adding remote: %s", remote->addrstr);
- list_add(&remote->list, &scfg->remotes);
+ list_add(&remote->list, &server->remotes);
return true;
}
bool
-server_add_local(struct cfg *cfg, struct server *scfg, struct saddr *saddr)
+server_add_local(struct cfg *cfg, struct server *server, struct saddr *saddr)
{
struct server_local *local;
- if (!scfg || !saddr) {
+ if (!server || !saddr) {
error("missing arguments");
return false;
}
- if (scfg->task.dead)
+ if (server->task.dead)
return false;
local = zmalloc(sizeof(*local));
@@ -648,43 +648,43 @@ server_add_local(struct cfg *cfg, struct server *scfg, struct saddr *saddr)
}
local->local = *saddr;
- uring_task_init(&local->task, "local", &scfg->task, server_local_free);
+ uring_task_init(&local->task, "local", &server->task, server_local_free);
debug(DBG_SRV, "adding local: %s", saddr->addrstr);
- list_add(&local->list, &scfg->locals);
+ list_add(&local->list, &server->locals);
xfree(saddr);
return true;
}
bool
-server_add_rcon(struct cfg *cfg, struct server *scfg, struct saddr *rcon)
+server_add_rcon(struct cfg *cfg, struct server *server, struct saddr *rcon)
{
- if (!scfg || !rcon)
+ if (!server || !rcon)
return false;
- if (scfg->task.dead)
+ if (server->task.dead)
return false;
debug(DBG_SRV, "adding rcon: %s", rcon->addrstr);
- list_add(&rcon->list, &scfg->rcons);
+ list_add(&rcon->list, &server->rcons);
return true;
}
bool
-server_set_rcon_password(struct cfg *cfg, struct server *scfg,
+server_set_rcon_password(struct cfg *cfg, struct server *server,
const char *password)
{
- return set_property(cfg, scfg, &scfg->rcon_password, password);
+ return set_property(cfg, server, &server->rcon_password, password);
}
bool
-server_set_systemd_service(struct cfg *cfg, struct server *scfg,
+server_set_systemd_service(struct cfg *cfg, struct server *server,
const char *service)
{
const char *suffix;
char *tmp;
- if (!cfg || !scfg || empty_str(service) || scfg->systemd_service)
+ if (!cfg || !server || empty_str(service) || server->systemd_service)
return false;
suffix = strrchr(service, '.');
@@ -700,78 +700,78 @@ server_set_systemd_service(struct cfg *cfg, struct server *scfg,
return false;
}
- scfg->systemd_service = tmp;
+ server->systemd_service = tmp;
return true;
}
bool
-server_set_stop_method(struct cfg *cfg, struct server *scfg,
+server_set_stop_method(struct cfg *cfg, struct server *server,
enum server_stop_method stop_method)
{
- if (scfg->stop_method != SERVER_STOP_METHOD_UNDEFINED ||
+ if (server->stop_method != SERVER_STOP_METHOD_UNDEFINED ||
stop_method == SERVER_STOP_METHOD_UNDEFINED)
return false;
- scfg->stop_method = stop_method;
+ server->stop_method = stop_method;
return true;
}
bool
-server_set_start_method(struct cfg *cfg, struct server *scfg,
+server_set_start_method(struct cfg *cfg, struct server *server,
enum server_start_method start_method)
{
- if (scfg->start_method != SERVER_START_METHOD_UNDEFINED ||
+ if (server->start_method != SERVER_START_METHOD_UNDEFINED ||
start_method == SERVER_START_METHOD_UNDEFINED)
return false;
- scfg->start_method = start_method;
+ server->start_method = start_method;
return true;
}
bool
-server_set_stop_exec(struct cfg *cfg, struct server *scfg, const char *cmd)
+server_set_stop_exec(struct cfg *cfg, struct server *server, const char *cmd)
{
- return set_property(cfg, scfg, &scfg->stop_exec, cmd);
+ return set_property(cfg, server, &server->stop_exec, cmd);
}
bool
-server_set_start_exec(struct cfg *cfg, struct server *scfg, const char *cmd)
+server_set_start_exec(struct cfg *cfg, struct server *server, const char *cmd)
{
- return set_property(cfg, scfg, &scfg->start_exec, cmd);
+ return set_property(cfg, server, &server->start_exec, cmd);
}
bool
-server_set_idle_timeout(struct cfg *cfg, struct server *scfg, uint16_t timeout)
+server_set_idle_timeout(struct cfg *cfg, struct server *server, uint16_t timeout)
{
- if (!scfg || scfg->idle_timeout != 0)
+ if (!server || server->idle_timeout != 0)
return false;
- scfg->idle_timeout = timeout;
+ server->idle_timeout = timeout;
return true;
}
bool
-server_set_port(struct cfg *cfg, struct server *scfg, uint16_t port)
+server_set_port(struct cfg *cfg, struct server *server, uint16_t port)
{
- if (!scfg || scfg->announce_port != 0)
+ if (!server || server->announce_port != 0)
return false;
- scfg->announce_port = htons(port);
+ server->announce_port = htons(port);
return true;
}
bool
-server_set_type(struct cfg *cfg, struct server *scfg, enum server_type type)
+server_set_type(struct cfg *cfg, struct server *server, enum server_type type)
{
- if (!scfg || scfg->type != SERVER_TYPE_UNDEFINED)
+ if (!server || server->type != SERVER_TYPE_UNDEFINED)
return false;
switch (type) {
case SERVER_TYPE_ANNOUNCE:
- scfg->type = SERVER_TYPE_ANNOUNCE;
+ server->type = SERVER_TYPE_ANNOUNCE;
break;
case SERVER_TYPE_PROXY:
- scfg->type = SERVER_TYPE_PROXY;
+ server->type = SERVER_TYPE_PROXY;
break;
default:
return false;
@@ -781,46 +781,46 @@ server_set_type(struct cfg *cfg, struct server *scfg, enum server_type type)
}
bool
-server_set_pretty_name(struct cfg *cfg, struct server *scfg, const char *pretty_name)
+server_set_pretty_name(struct cfg *cfg, struct server *server, const char *pretty_name)
{
- return set_property(cfg, scfg, &scfg->pretty_name, pretty_name);
+ return set_property(cfg, server, &server->pretty_name, pretty_name);
}
struct server *
server_new(struct cfg *cfg, const char *name)
{
- struct server *scfg;
+ struct server *server;
- list_for_each_entry(scfg, &cfg->servers, list) {
- if (strcmp(name, scfg->name))
+ list_for_each_entry(server, &cfg->servers, list) {
+ if (strcmp(name, server->name))
continue;
error("attempt to add duplicate server: %s", name);
- return scfg;
+ return server;
}
verbose("Adding server %s", name);
- scfg = zmalloc(sizeof(*scfg));
- if (!scfg) {
+ server = zmalloc(sizeof(*server));
+ if (!server) {
error("malloc");
return NULL;
}
- scfg->state = SERVER_STATE_INIT;
- scfg->cfg = cfg;
- scfg->type = SERVER_TYPE_UNDEFINED;
- scfg->name = xstrdup(name);
- scfg->stop_method = SERVER_STOP_METHOD_UNDEFINED;
- scfg->start_method = SERVER_START_METHOD_UNDEFINED;
- uring_task_init(&scfg->task, "scfg", uring_parent(cfg), server_free);
- uring_task_set_buf(&scfg->task, &scfg->tbuf);
- uring_task_init(&scfg->exec_task, "exec", &scfg->task, server_exec_free);
- list_init(&scfg->remotes);
- list_init(&scfg->locals);
- list_init(&scfg->proxys);
- list_init(&scfg->rcons);
- list_init(&scfg->dnslookups);
- scfg->idle_timeout = 0;
- list_add(&scfg->list, &cfg->servers);
-
- return scfg;
+ server->state = SERVER_STATE_INIT;
+ server->cfg = cfg;
+ server->type = SERVER_TYPE_UNDEFINED;
+ server->name = xstrdup(name);
+ server->stop_method = SERVER_STOP_METHOD_UNDEFINED;
+ server->start_method = SERVER_START_METHOD_UNDEFINED;
+ uring_task_init(&server->task, "server", uring_parent(cfg), server_free);
+ uring_task_set_buf(&server->task, &server->tbuf);
+ uring_task_init(&server->exec_task, "exec", &server->task, server_exec_free);
+ list_init(&server->remotes);
+ list_init(&server->locals);
+ list_init(&server->proxys);
+ list_init(&server->rcons);
+ list_init(&server->dnslookups);
+ server->idle_timeout = 0;
+ list_add(&server->list, &cfg->servers);
+
+ return server;
}
diff --git a/server.h b/server.h
index ae0503a..80400a1 100644
--- a/server.h
+++ b/server.h
@@ -74,49 +74,49 @@ struct server {
void server_refdump(struct server *server);
-void server_delete(struct cfg *cfg, struct server *scfg);
+void server_delete(struct cfg *cfg, struct server *server);
void server_delete_by_name(struct cfg *cfg, const char *name);
-bool server_start(struct cfg *cfg, struct server *scfg);
+bool server_start(struct cfg *cfg, struct server *server);
-bool server_stop(struct cfg *cfg, struct server *scfg);
+bool server_stop(struct cfg *cfg, struct server *server);
-bool server_commit(struct cfg *cfg, struct server *scfg);
+bool server_commit(struct cfg *cfg, struct server *server);
-bool server_add_remote(struct cfg *cfg, struct server *scfg,
+bool server_add_remote(struct cfg *cfg, struct server *server,
struct saddr *remote);
-bool server_add_local(struct cfg *cfg, struct server *scfg,
+bool server_add_local(struct cfg *cfg, struct server *server,
struct saddr *saddr);
-bool server_add_rcon(struct cfg *cfg, struct server *scfg,
+bool server_add_rcon(struct cfg *cfg, struct server *server,
struct saddr *rcon);
-bool server_set_rcon_password(struct cfg *cfg, struct server *scfg,
+bool server_set_rcon_password(struct cfg *cfg, struct server *server,
const char *password);
-bool server_set_systemd_service(struct cfg *cfg, struct server *scfg,
+bool server_set_systemd_service(struct cfg *cfg, struct server *server,
const char *service);
-bool server_set_stop_method(struct cfg *cfg, struct server *scfg,
+bool server_set_stop_method(struct cfg *cfg, struct server *server,
enum server_stop_method stop_method);
-bool server_set_start_method(struct cfg *cfg, struct server *scfg,
+bool server_set_start_method(struct cfg *cfg, struct server *server,
enum server_start_method start_method);
-bool server_set_stop_exec(struct cfg *cfg, struct server *scfg, const char *cmd);
+bool server_set_stop_exec(struct cfg *cfg, struct server *server, const char *cmd);
-bool server_set_start_exec(struct cfg *cfg, struct server *scfg, const char *cmd);
+bool server_set_start_exec(struct cfg *cfg, struct server *server, const char *cmd);
-bool server_set_idle_timeout(struct cfg *cfg, struct server *scfg, uint16_t timeout);
+bool server_set_idle_timeout(struct cfg *cfg, struct server *server, uint16_t timeout);
-bool server_set_port(struct cfg *cfg, struct server *scfg, uint16_t port);
+bool server_set_port(struct cfg *cfg, struct server *server, uint16_t port);
-bool server_set_type(struct cfg *cfg, struct server *scfg,
+bool server_set_type(struct cfg *cfg, struct server *server,
enum server_type type);
-bool server_set_pretty_name(struct cfg *cfg, struct server *scfg,
+bool server_set_pretty_name(struct cfg *cfg, struct server *server,
const char *pretty_name);
struct server *server_new(struct cfg *cfg, const char *name);