2021-10-07 18:02:40 +00: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-06-09 08:51:45 +00:00
|
|
|
index c8012de68b997d6270ba4a5d79bc93c09ff4354f..1429f938c36d5a3a33e71837f440b2303d60cfe7 100644
|
2021-10-07 18:02:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -51,10 +51,11 @@ public class PacketUtils {
|
|
|
|
packet.handle(listener);
|
|
|
|
} catch (Exception exception) {
|
|
|
|
net.minecraft.network.Connection networkmanager = listener.getConnection();
|
2022-06-09 08:51:45 +00:00
|
|
|
+ String playerIP = io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? String.valueOf(networkmanager.getRemoteAddress()) : "<ip address withheld>"; // Paper
|
2021-10-07 18:02:40 +00:00
|
|
|
if (networkmanager.getPlayer() != null) {
|
2022-03-01 05:43:03 +00: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 18:02:40 +00:00
|
|
|
} else {
|
2022-03-01 05:43:03 +00: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 18:02:40 +00:00
|
|
|
}
|
2022-06-08 11:44:30 +00:00
|
|
|
net.minecraft.network.chat.Component error = net.minecraft.network.chat.Component.literal("Packet processing error");
|
2022-03-01 05:43:03 +00:00
|
|
|
networkmanager.send(new net.minecraft.network.protocol.game.ClientboundDisconnectPacket(error), (future) -> {
|
2021-10-07 18:02:40 +00: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-21 19:53:04 +00:00
|
|
|
index 0d35e9ff88542b02bb948aa10e064911e73a6913..31a4cd5010cd4ed8eb64b2bad86dc3adfd8ecca8 100644
|
2021-10-07 18:02:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
|
2022-03-01 05:43:03 +00:00
|
|
|
@@ -183,7 +183,7 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
|
2021-10-07 18:02:40 +00:00
|
|
|
buf.release();
|
|
|
|
this.buf = null;
|
|
|
|
|
|
|
|
- LOGGER.debug("Ping: (1.6) from {}", ctx.channel().remoteAddress());
|
2022-06-09 08:51:45 +00: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 18:02:40 +00:00
|
|
|
|
|
|
|
InetSocketAddress virtualHost = com.destroystokyo.paper.network.PaperNetworkClient.prepareVirtualHost(host, port);
|
2022-03-01 05:43:03 +00:00
|
|
|
com.destroystokyo.paper.event.server.PaperServerListPingEvent event = com.destroystokyo.paper.network.PaperLegacyStatusClient.processRequest(
|
2021-10-07 18:02:40 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
2022-06-09 08:51:45 +00:00
|
|
|
index af3e70920221b6bd127bb3aed7f1e0a7e9e4c322..597c7660bd517322d8bc9c5acef6956c40067405 100644
|
2021-10-07 18:02:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
2022-06-08 11:44:30 +00:00
|
|
|
@@ -205,7 +205,7 @@ public class ServerConnectionListener {
|
2021-10-07 18:02:40 +00:00
|
|
|
throw new ReportedException(CrashReport.forThrowable(exception, "Ticking memory connection"));
|
|
|
|
}
|
|
|
|
|
|
|
|
- ServerConnectionListener.LOGGER.warn("Failed to handle packet for {}", networkmanager.getRemoteAddress(), exception);
|
2022-06-09 08:51:45 +00: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 11:44:30 +00:00
|
|
|
MutableComponent ichatmutablecomponent = Component.literal("Internal server error");
|
2021-10-07 18:02:40 +00:00
|
|
|
|
2022-06-08 11:44:30 +00:00
|
|
|
networkmanager.send(new ClientboundDisconnectPacket(ichatmutablecomponent), (future) -> {
|
2021-10-07 18:02:40 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
2022-07-21 19:53:04 +00:00
|
|
|
index 5064ea6767ce17dde271e80f4360549462f6cca0..c098a602ce840db0099b15bd108ea873c7f111d4 100644
|
2021-10-07 18:02:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
2022-06-09 08:51:45 +00:00
|
|
|
@@ -229,7 +229,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
|
2021-10-07 18:02:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getUserName() {
|
|
|
|
- return this.gameProfile != null ? this.gameProfile + " (" + this.connection.getRemoteAddress() + ")" : String.valueOf(this.connection.getRemoteAddress());
|
|
|
|
+ // Paper start
|
2022-06-09 08:51:45 +00:00
|
|
|
+ String ip = io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? String.valueOf(this.connection.getRemoteAddress()) : "<ip address withheld>";
|
2021-10-07 18:02:40 +00:00
|
|
|
+ return this.gameProfile != null ? this.gameProfile + " (" + ip + ")" : String.valueOf(ip);
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
2022-06-08 11:44:30 +00:00
|
|
|
@Nullable
|
2021-10-07 18:02:40 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2022-06-09 08:51:45 +00:00
|
|
|
index bf2888b678567ace5959d989e5dd119c65a9500d..d74d6669005d0669503253787636756a0c6590f4 100644
|
2021-10-07 18:02:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2022-06-08 11:44:30 +00:00
|
|
|
@@ -240,7 +240,7 @@ public abstract class PlayerList {
|
2022-01-14 03:56:45 +00:00
|
|
|
final String s1;
|
2021-10-07 18:02:40 +00:00
|
|
|
|
|
|
|
if (connection.getRemoteAddress() != null) {
|
|
|
|
- s1 = connection.getRemoteAddress().toString();
|
2022-06-09 08:51:45 +00:00
|
|
|
+ s1 = io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? connection.getRemoteAddress().toString() : "<ip address withheld>"; // Paper
|
2022-01-14 03:56:45 +00:00
|
|
|
} else {
|
|
|
|
s1 = "local";
|
2021-10-07 18:02:40 +00:00
|
|
|
}
|