From 2c9ba58d3142243b439dd83b254b1e6eba94d52c Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Sun, 5 Jul 2020 19:04:13 +0200 Subject: Add per-server announce setting --- minecproxy/main.c | 6 +++--- minecproxy/server.c | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'minecproxy') 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); -- cgit v1.2.3