From 9fa3a8fd65aae7504734cc8c4515ff6696cee73d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 26 Jan 2022 03:22:52 +0200 Subject: [PATCH 28/28] Add iphide server setting Requested by barg See osdn #43683 Signed-off-by: Marko Lindqvist --- common/game.h | 3 +++ server/connecthand.c | 33 +++++++++++++++++++++++++-------- server/settings.c | 9 +++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/common/game.h b/common/game.h index 1ed67f1025..191ab45b19 100644 --- a/common/game.h +++ b/common/game.h @@ -170,6 +170,7 @@ struct civ_game { int onsetbarbarian; int pingtime; int pingtimeout; + bool ip_hide; int ransom_gold; int razechance; unsigned revealmap; @@ -614,6 +615,8 @@ extern struct world wld; #define GAME_MIN_PINGTIMEOUT 60 #define GAME_MAX_PINGTIMEOUT 1800 +#define GAME_DEFAULT_IPHIDE FALSE + #define GAME_DEFAULT_NOTRADESIZE 0 #define GAME_MIN_NOTRADESIZE 0 #define GAME_MAX_NOTRADESIZE 49 diff --git a/server/connecthand.c b/server/connecthand.c index b70a8c2e72..538ca5d93c 100644 --- a/server/connecthand.c +++ b/server/connecthand.c @@ -270,14 +270,27 @@ void establish_new_connection(struct connection *pconn) * sent the pending events to pconn (from this function and also * connection_attach()), otherwise pconn will receive it too. */ if (conn_controls_player(pconn)) { - package_event(&connect_info, NULL, E_CONNECTION, ftc_server, - _("%s has connected from %s (player %s)."), - pconn->username, pconn->addr, - player_name(conn_get_player(pconn))); + if (game.server.ip_hide) { + package_event(&connect_info, NULL, E_CONNECTION, ftc_server, + _("%s has connected (player %s)."), + pconn->username, + player_name(conn_get_player(pconn))); + } else { + package_event(&connect_info, NULL, E_CONNECTION, ftc_server, + _("%s has connected from %s (player %s)."), + pconn->username, pconn->addr, + player_name(conn_get_player(pconn))); + } } else { - package_event(&connect_info, NULL, E_CONNECTION, ftc_server, - _("%s has connected from %s."), - pconn->username, pconn->addr); + if (game.server.ip_hide) { + package_event(&connect_info, NULL, E_CONNECTION, ftc_server, + _("%s has connected."), + pconn->username); + } else { + package_event(&connect_info, NULL, E_CONNECTION, ftc_server, + _("%s has connected from %s."), + pconn->username, pconn->addr); + } } conn_list_iterate(game.est_connections, aconn) { if (aconn != pconn) { @@ -510,7 +523,11 @@ static void package_conn_info(struct connection *pconn, packet->access_level = pconn->access_level; sz_strlcpy(packet->username, pconn->username); - sz_strlcpy(packet->addr, pconn->addr); + if (game.server.ip_hide) { + sz_strlcpy(packet->addr, Q_("?IP:Hidden")); + } else { + sz_strlcpy(packet->addr, pconn->addr); + } sz_strlcpy(packet->capability, pconn->capability); } diff --git a/server/settings.c b/server/settings.c index 74f9f5d12f..b0a0f290a6 100644 --- a/server/settings.c +++ b/server/settings.c @@ -2867,6 +2867,15 @@ static struct setting settings[] = { "client is disconnected."), NULL, NULL, NULL, GAME_MIN_PINGTIMEOUT, GAME_MAX_PINGTIMEOUT, GAME_DEFAULT_PINGTIMEOUT) + GEN_BOOL("iphide", game.server.ip_hide, + SSET_META, SSET_NETWORK, SSET_RARE, + ALLOW_NONE, ALLOW_HACK, + N_("Keep client IP hidden"), + N_("Don't tell client IP address to other clients. Server operator " + "can still see it. Also, changing this setting cannot do anything " + "to the information already sent before."), + NULL, NULL, GAME_DEFAULT_IPHIDE) + GEN_BOOL("turnblock", game.server.turnblock, SSET_META, SSET_INTERNAL, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC, -- 2.34.1