Add option to not log player IP addresses

Resolves #3246
This commit is contained in:
Camotoy 2022-08-25 16:10:43 -04:00
parent 6ec1ba39c6
commit 29fcce7ec8
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
5 changed files with 13 additions and 4 deletions

View File

@ -105,6 +105,8 @@ public interface GeyserConfiguration {
int getCustomSkullRenderDistance(); int getCustomSkullRenderDistance();
boolean isLogPlayerIpAddresses();
boolean isNotifyOnNewBedrockUpdate(); boolean isNotifyOnNewBedrockUpdate();
IMetricsInfo getMetrics(); IMetricsInfo getMetrics();

View File

@ -148,6 +148,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
@JsonProperty("xbox-achievements-enabled") @JsonProperty("xbox-achievements-enabled")
private boolean xboxAchievementsEnabled = false; private boolean xboxAchievementsEnabled = false;
@JsonProperty("log-player-ip-addresses")
private boolean logPlayerIpAddresses = true;
@JsonProperty("notify-on-new-bedrock-update") @JsonProperty("notify-on-new-bedrock-update")
private boolean notifyOnNewBedrockUpdate = true; private boolean notifyOnNewBedrockUpdate = true;

View File

@ -84,14 +84,16 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
} }
} }
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.attempt_connect", inetSocketAddress)); String ip = geyser.getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.attempt_connect", ip));
return true; return true;
} }
@Override @Override
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) { public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
if (geyser.getConfig().isDebugMode() && PRINT_DEBUG_PINGS) { if (geyser.getConfig().isDebugMode() && PRINT_DEBUG_PINGS) {
geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.network.pinged", inetSocketAddress)); String ip = geyser.getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.network.pinged", ip));
} }
GeyserConfiguration config = geyser.getConfig(); GeyserConfiguration config = geyser.getConfig();

View File

@ -135,7 +135,6 @@ import org.geysermc.geyser.util.MathUtils;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Instant; import java.time.Instant;
@ -1045,7 +1044,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
} else { } else {
// Downstream's disconnect will fire an event that prints a log message // Downstream's disconnect will fire an event that prints a log message
// Otherwise, we print a message here // Otherwise, we print a message here
InetAddress address = upstream.getAddress().getAddress(); String address = geyser.getConfig().isLogPlayerIpAddresses() ? upstream.getAddress().getAddress().toString() : "<IP address withheld>";
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.disconnect", address, reason)); geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.disconnect", address, reason));
} }
if (!upstream.isClosed()) { if (!upstream.isClosed()) {

View File

@ -175,6 +175,9 @@ force-resource-packs: true
# THIS DISABLES ALL COMMANDS FROM SUCCESSFULLY RUNNING FOR BEDROCK IN-GAME, as otherwise Bedrock thinks you are cheating. # THIS DISABLES ALL COMMANDS FROM SUCCESSFULLY RUNNING FOR BEDROCK IN-GAME, as otherwise Bedrock thinks you are cheating.
xbox-achievements-enabled: false xbox-achievements-enabled: false
# Whether player IP addresses will be logged by the server.
log-player-ip-addresses: true
# Whether to alert the console and operators that a new Geyser version is available that supports a Bedrock version # Whether to alert the console and operators that a new Geyser version is available that supports a Bedrock version
# that this Geyser version does not support. It's recommended to keep this option enabled, as many Bedrock platforms # that this Geyser version does not support. It's recommended to keep this option enabled, as many Bedrock platforms
# auto-update. # auto-update.