summaryrefslogtreecommitdiff
path: root/minecproxy
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-07-05 19:04:13 +0200
committerDavid Härdeman <david@hardeman.nu>2020-07-05 19:04:13 +0200
commit2c9ba58d3142243b439dd83b254b1e6eba94d52c (patch)
tree3bda6601ff665951b271f5989869e7aa23afc972 /minecproxy
parent45af0d8c8603f037efe5f7bc1b1020b9cc42acdd (diff)
Add per-server announce setting
Diffstat (limited to 'minecproxy')
-rw-r--r--minecproxy/main.c6
-rw-r--r--minecproxy/server.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/minecproxy/main.c b/minecproxy/main.c
index 54a0d7b..6ec92ba 100644
--- a/minecproxy/main.c
+++ b/minecproxy/main.c
@@ -187,7 +187,7 @@ enum mcfg_keys {
MCFG_KEY_INVALID = 0,
MCFG_KEY_IGMP,
MCFG_KEY_IGMP_IFACE,
- MCFG_KEY_ANN_INTERVAL,
+ MCFG_KEY_ANNOUNCE_INTERVAL,
MCFG_KEY_PROXY_CONN_INTERVAL,
MCFG_KEY_PROXY_CONN_ATTEMPTS,
MCFG_KEY_SOCKET_DEFER,
@@ -210,7 +210,7 @@ struct cfg_key_value_map mcfg_key_map[] = {
},
{
.key_name = "announce_interval",
- .key_value = MCFG_KEY_ANN_INTERVAL,
+ .key_value = MCFG_KEY_ANNOUNCE_INTERVAL,
.value_type = CFG_VAL_TYPE_UINT16,
},
{
@@ -332,7 +332,7 @@ static void cfg_read()
break;
- case MCFG_KEY_ANN_INTERVAL:
+ case MCFG_KEY_ANNOUNCE_INTERVAL:
cfg->announce_interval = value.uint16;
break;
diff --git a/minecproxy/server.c b/minecproxy/server.c
index 84a50ee..85019b4 100644
--- a/minecproxy/server.c
+++ b/minecproxy/server.c
@@ -91,6 +91,7 @@ void server_delete_by_filename(const char *filename)
}
}
+/* FIXME: Share with minecctl */
static void server_dump(struct server *server)
{
struct server_local *local;
@@ -400,7 +401,10 @@ bool server_announce(struct server *server, int fd)
assert_return(server && fd >= 0, false);
if (server->state == SERVER_STATE_INIT ||
- server->state == SERVER_STATE_DEAD)
+ server->state == SERVER_STATE_DEAD ||
+ server->scfg.announce == SERVER_ANNOUNCE_NEVER ||
+ (server->scfg.announce == SERVER_ANNOUNCE_WHEN_RUNNING &&
+ server->state != SERVER_STATE_RUNNING))
return false;
debug(DBG_ANN, "announcing server: %s", server->name);