2021-10-07 20:02:40 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Noah van der Aa <ndvdaa@gmail.com>
|
|
|
|
Date: Tue, 5 Oct 2021 20:04:21 +0200
|
|
|
|
Subject: [PATCH] Add config option for logging player ip addresses
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2021-11-27 11:42:09 +01:00
|
|
|
index eaa1d5491ef3f5caf156d16fa7544741e53c6bab..cd918cec00d8202252af0d20b1a8891371c538e3 100644
|
2021-10-07 20:02:40 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2021-11-25 09:10:26 +01:00
|
|
|
@@ -91,6 +91,11 @@ public class PaperConfig {
|
2021-10-07 20:02:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public static boolean logPlayerIpAddresses = true;
|
|
|
|
+ private static void playerIpAddresses() {
|
|
|
|
+ logPlayerIpAddresses = getBoolean("settings.log-player-ip-addresses", logPlayerIpAddresses);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
public static int maxJoinsPerTick;
|
|
|
|
private static void maxJoinsPerTick() {
|
|
|
|
maxJoinsPerTick = getInt("settings.max-joins-per-tick", 3);
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
|
|
index acc12307f61e1e055896b68fe16654c9c4a606a0..c958a00535c0f7a015a7a566b97e2c80fc9a0efd 100644
|
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
|
|
@@ -58,10 +58,11 @@ public class PacketUtils {
|
|
|
|
// Paper start
|
|
|
|
catch (Exception e) {
|
|
|
|
Connection networkmanager = listener.getConnection();
|
|
|
|
+ String playerIP = com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? String.valueOf(networkmanager.getRemoteAddress()) : "<ip address withheld>"; // Paper
|
|
|
|
if (networkmanager.getPlayer() != null) {
|
|
|
|
- LOGGER.error("Error whilst processing packet {} for {}[{}]", packet, networkmanager.getPlayer().getScoreboardName(), networkmanager.getRemoteAddress(), e);
|
|
|
|
+ LOGGER.error("Error whilst processing packet {} for {}[{}]", packet, networkmanager.getPlayer().getScoreboardName(), playerIP, e); // Paper
|
|
|
|
} else {
|
|
|
|
- LOGGER.error("Error whilst processing packet {} for connection from {}", packet, networkmanager.getRemoteAddress(), e);
|
|
|
|
+ LOGGER.error("Error whilst processing packet {} for connection from {}", packet, playerIP, e); // Paper
|
|
|
|
}
|
|
|
|
TextComponent error = new TextComponent("Packet processing error");
|
|
|
|
networkmanager.send(new ClientboundDisconnectPacket(error), (future) -> {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
|
|
|
|
index 3962e82d4e4c5f792a37e825891e6960e737452d..dddc97094f0a7847b2818e6ea3b3f6cd4eb72b38 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
|
|
|
|
@@ -185,7 +185,7 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
buf.release();
|
|
|
|
this.buf = null;
|
|
|
|
|
|
|
|
- LOGGER.debug("Ping: (1.6) from {}", ctx.channel().remoteAddress());
|
|
|
|
+ LOGGER.debug("Ping: (1.6) from {}", com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? ctx.channel().remoteAddress() : "<ip address withheld>"); // Paper
|
|
|
|
|
|
|
|
InetSocketAddress virtualHost = com.destroystokyo.paper.network.PaperNetworkClient.prepareVirtualHost(host, port);
|
|
|
|
com.destroystokyo.paper.event.server.PaperServerListPingEvent event = PaperLegacyStatusClient.processRequest(
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
2021-11-25 09:10:26 +01:00
|
|
|
index 477aa83c3b342705a8a9b7ab41b2f77008e2e281..a821b68fbe7e172c08540e4b04c857b8b5929120 100644
|
2021-10-07 20:02:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
|
|
|
@@ -204,7 +204,7 @@ public class ServerConnectionListener {
|
|
|
|
throw new ReportedException(CrashReport.forThrowable(exception, "Ticking memory connection"));
|
|
|
|
}
|
|
|
|
|
|
|
|
- ServerConnectionListener.LOGGER.warn("Failed to handle packet for {}", networkmanager.getRemoteAddress(), exception);
|
|
|
|
+ ServerConnectionListener.LOGGER.warn("Failed to handle packet for {}", com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? String.valueOf(networkmanager.getRemoteAddress()) : "<ip address withheld>", exception); // Paper
|
|
|
|
TextComponent chatcomponenttext = new TextComponent("Internal server error");
|
|
|
|
|
|
|
|
networkmanager.send(new ClientboundDisconnectPacket(chatcomponenttext), (future) -> {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
2021-11-25 09:10:26 +01:00
|
|
|
index d2dd8b802ecea7fd2efe5f07fcef65c26e1adfbc..33a29890435d6065a2cc4f8e8bf8209c01d5d114 100644
|
2021-10-07 20:02:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
2021-11-25 09:10:26 +01:00
|
|
|
@@ -224,7 +224,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
|
2021-10-07 20:02:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getUserName() {
|
|
|
|
- return this.gameProfile != null ? this.gameProfile + " (" + this.connection.getRemoteAddress() + ")" : String.valueOf(this.connection.getRemoteAddress());
|
|
|
|
+ // Paper start
|
|
|
|
+ String ip = com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? String.valueOf(this.connection.getRemoteAddress()) : "<ip address withheld>";
|
|
|
|
+ return this.gameProfile != null ? this.gameProfile + " (" + ip + ")" : String.valueOf(ip);
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2021-11-27 11:42:09 +01:00
|
|
|
index 92a3df6d2435d8800a8173e7be3ba11577f23b5a..24111c47145b296c442982affdbfe045c52386e1 100644
|
2021-10-07 20:02:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2021-11-25 09:54:06 +01:00
|
|
|
@@ -237,7 +237,7 @@ public abstract class PlayerList {
|
2021-10-07 20:02:40 +02:00
|
|
|
String s1 = "local";
|
|
|
|
|
|
|
|
if (connection.getRemoteAddress() != null) {
|
|
|
|
- s1 = connection.getRemoteAddress().toString();
|
|
|
|
+ s1 = com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? connection.getRemoteAddress().toString() : "<ip address withheld>"; // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
// Spigot start - spawn location event
|
2021-11-25 09:54:06 +01:00
|
|
|
@@ -300,7 +300,7 @@ public abstract class PlayerList {
|
2021-10-08 09:30:52 +02:00
|
|
|
playerconnection.playerJoinReady = () -> {
|
|
|
|
postChunkLoadJoin(
|
|
|
|
player, finalWorldserver, connection, playerconnection,
|
|
|
|
- nbttagcompound, connection.getRemoteAddress().toString(), lastKnownName
|
|
|
|
+ nbttagcompound, com.destroystokyo.paper.PaperConfig.logPlayerIpAddresses ? connection.getRemoteAddress().toString() : "<ip address withheld>", lastKnownName // Paper
|
|
|
|
);
|
|
|
|
};
|
|
|
|
});
|