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/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
2022-07-28 00:20:14 +02:00
|
|
|
index d6f3869f5725c7f081efb7f486f74dbb99d4d005..8bc0cb9ad5bb4e76d962ff54305e2c08e279a17b 100644
|
2021-10-07 20:02:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
2022-03-01 06:43:03 +01:00
|
|
|
@@ -51,10 +51,11 @@ public class PacketUtils {
|
|
|
|
packet.handle(listener);
|
|
|
|
} catch (Exception exception) {
|
|
|
|
net.minecraft.network.Connection networkmanager = listener.getConnection();
|
2022-06-09 10:51:45 +02:00
|
|
|
+ String playerIP = io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? String.valueOf(networkmanager.getRemoteAddress()) : "<ip address withheld>"; // Paper
|
2021-10-07 20:02:40 +02:00
|
|
|
if (networkmanager.getPlayer() != null) {
|
2022-03-01 06:43:03 +01:00
|
|
|
- LOGGER.error("Error whilst processing packet {} for {}[{}]", packet, networkmanager.getPlayer().getScoreboardName(), networkmanager.getRemoteAddress(), exception);
|
|
|
|
+ LOGGER.error("Error whilst processing packet {} for {}[{}]", packet, networkmanager.getPlayer().getScoreboardName(), playerIP, exception); // Paper
|
2021-10-07 20:02:40 +02:00
|
|
|
} else {
|
2022-03-01 06:43:03 +01:00
|
|
|
- LOGGER.error("Error whilst processing packet {} for connection from {}", packet, networkmanager.getRemoteAddress(), exception);
|
|
|
|
+ LOGGER.error("Error whilst processing packet {} for connection from {}", packet, playerIP, exception); // Paper
|
2021-10-07 20:02:40 +02:00
|
|
|
}
|
2022-06-08 13:44:30 +02:00
|
|
|
net.minecraft.network.chat.Component error = net.minecraft.network.chat.Component.literal("Packet processing error");
|
2022-07-28 00:20:14 +02:00
|
|
|
networkmanager.send(new net.minecraft.network.protocol.game.ClientboundDisconnectPacket(error), net.minecraft.network.PacketSendListener.thenRun(() -> networkmanager.disconnect(error)));
|
2021-10-07 20:02:40 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
|
2022-07-27 23:32:15 +02:00
|
|
|
index 37cd7b44559e5705b31296df87c94d2ab200138d..37e52ea9ab694b466358981bc2a3c99f28a70c7d 100644
|
2021-10-07 20:02:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
|
2022-07-27 23:32:15 +02:00
|
|
|
@@ -185,7 +185,7 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
|
2021-10-07 20:02:40 +02:00
|
|
|
buf.release();
|
|
|
|
this.buf = null;
|
|
|
|
|
|
|
|
- LOGGER.debug("Ping: (1.6) from {}", ctx.channel().remoteAddress());
|
2022-06-09 10:51:45 +02:00
|
|
|
+ LOGGER.debug("Ping: (1.6) from {}", io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? ctx.channel().remoteAddress() : "<ip address withheld>"); // Paper
|
2021-10-07 20:02:40 +02:00
|
|
|
|
|
|
|
InetSocketAddress virtualHost = com.destroystokyo.paper.network.PaperNetworkClient.prepareVirtualHost(host, port);
|
2022-03-01 06:43:03 +01:00
|
|
|
com.destroystokyo.paper.event.server.PaperServerListPingEvent event = com.destroystokyo.paper.network.PaperLegacyStatusClient.processRequest(
|
2021-10-07 20:02:40 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
2022-07-27 23:32:15 +02:00
|
|
|
index 2985271132c9ae822dcb0d7a7e6f0c268d1736cc..cfdbcd024de6ad0f9d4e83b2f912b36ef3299458 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
|
2022-07-27 23:32:15 +02:00
|
|
|
@@ -206,7 +206,7 @@ public class ServerConnectionListener {
|
2021-10-07 20:02:40 +02:00
|
|
|
throw new ReportedException(CrashReport.forThrowable(exception, "Ticking memory connection"));
|
|
|
|
}
|
|
|
|
|
|
|
|
- ServerConnectionListener.LOGGER.warn("Failed to handle packet for {}", networkmanager.getRemoteAddress(), exception);
|
2022-06-09 10:51:45 +02:00
|
|
|
+ ServerConnectionListener.LOGGER.warn("Failed to handle packet for {}", io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? String.valueOf(networkmanager.getRemoteAddress()) : "<ip address withheld>", exception); // Paper
|
2022-06-08 13:44:30 +02:00
|
|
|
MutableComponent ichatmutablecomponent = Component.literal("Internal server error");
|
2021-10-07 20:02:40 +02:00
|
|
|
|
2022-07-27 23:32:15 +02:00
|
|
|
networkmanager.send(new ClientboundDisconnectPacket(ichatmutablecomponent), PacketSendListener.thenRun(() -> {
|
2021-10-07 20:02:40 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
2022-10-02 09:56:36 +02:00
|
|
|
index 2bbf4096ec6c992a0369964efdd1375ae11b62d4..b87bd1c2d3a371e2fca1d0bff6d0985188b22584 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
|
2022-09-17 23:58:51 +02:00
|
|
|
@@ -226,7 +226,10 @@ public class ServerLoginPacketListenerImpl implements TickablePacketListener, Se
|
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
|
2022-06-09 10:51:45 +02:00
|
|
|
+ String ip = io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? String.valueOf(this.connection.getRemoteAddress()) : "<ip address withheld>";
|
2021-10-07 20:02:40 +02:00
|
|
|
+ return this.gameProfile != null ? this.gameProfile + " (" + ip + ")" : String.valueOf(ip);
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2022-06-08 13:44:30 +02:00
|
|
|
@Nullable
|
2021-10-07 20:02:40 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2022-09-26 10:02:51 +02:00
|
|
|
index 456031783aa902c8fd40050aa2b8d051b996d71d..3e870218321a701b814a4dac97ff1af12142600e 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
|
2022-09-01 18:51:59 +02:00
|
|
|
@@ -243,7 +243,7 @@ public abstract class PlayerList {
|
2022-01-14 04:56:45 +01:00
|
|
|
final String s1;
|
2021-10-07 20:02:40 +02:00
|
|
|
|
|
|
|
if (connection.getRemoteAddress() != null) {
|
|
|
|
- s1 = connection.getRemoteAddress().toString();
|
2022-06-09 10:51:45 +02:00
|
|
|
+ s1 = io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? connection.getRemoteAddress().toString() : "<ip address withheld>"; // Paper
|
2022-01-14 04:56:45 +01:00
|
|
|
} else {
|
|
|
|
s1 = "local";
|
2021-10-07 20:02:40 +02:00
|
|
|
}
|