Added the option to hide IP addresses in logs

This commit is contained in:
MrSlenky
2022-07-10 17:44:07 +02:00
parent 42559d83f0
commit 69dc6eaa7d
3 changed files with 24 additions and 0 deletions
@@ -304,9 +304,13 @@ public class ClientConnection extends Thread {
//legacy ping
if (handShakeSize == 0xFE) {
ServerProperties properties = Limbo.getInstance().getServerProperties();
state = ClientState.LEGACY;
channel.output.writeByte(255);
String str = inetAddress.getHostName() + ":" + clientSocket.getPort();
if(!properties.isLogPlayerIPAddresses())
str = "<ip address withheld>" + ":" + clientSocket.getPort();;
Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Legacy Status has pinged");
ServerProperties p = Limbo.getInstance().getServerProperties();
StatusPingEvent event = Limbo.getInstance().getEventsManager().callEvent(new StatusPingEvent(this, p.getVersionString(), p.getProtocol(), p.getMotd(), p.getMaxPlayers(), Limbo.getInstance().getPlayers().size(), p.getFavicon().orElse(null)));
@@ -336,7 +340,11 @@ public class ClientConnection extends Thread {
while (clientSocket.isConnected()) {
PacketIn packetIn = channel.readPacket();
if (packetIn instanceof PacketStatusInRequest) {
ServerProperties properties = Limbo.getInstance().getServerProperties();
String str = inetAddress.getHostName() + ":" + clientSocket.getPort();
if(!properties.isLogPlayerIPAddresses())
str = "<ip address withheld>" + ":" + clientSocket.getPort();;
if (Limbo.getInstance().getServerProperties().handshakeVerboseEnabled()) {
Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Handshake Status has pinged");
}
@@ -496,6 +504,9 @@ public class ClientConnection extends Thread {
sendPacket(abilities);
String str = inetAddress.getHostName() + ":" + clientSocket.getPort() + "|" + player.getName() + "(" + player.getUniqueId() + ")";
if(!properties.isLogPlayerIPAddresses())
str = "<ip address withheld>" + ":" + clientSocket.getPort() + "|" + player.getName() + "(" + player.getUniqueId() + ")";
Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Player had connected to the Limbo server!");
player.playerInteractManager.update();
@@ -664,6 +675,9 @@ public class ClientConnection extends Thread {
Limbo.getInstance().getEventsManager().callEvent(new PlayerQuitEvent(player));
str = inetAddress.getHostName() + ":" + clientSocket.getPort() + "|" + player.getName();
if(!properties.isLogPlayerIPAddresses())
str = "<ip address withheld>" + ":" + clientSocket.getPort() + clientSocket.getPort() + "|" + player.getName();
Limbo.getInstance().getConsole().sendMessage("[/" + str + "] <-> Player had disconnected!");
}