From de57563eaba845304cd4407ae75126ebe2def5c4 Mon Sep 17 00:00:00 2001 From: Pancake Date: Thu, 4 Jan 2024 14:50:47 +0100 Subject: [PATCH] Hide ip address in initial and legacy connections (#1025) --- .../proxy/connection/client/HandshakeSessionHandler.java | 7 ++++++- .../proxy/connection/client/InitialInboundConnection.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java index 079ce035f..2b5c171ae 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java @@ -236,7 +236,12 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler { @Override public String toString() { - return "[legacy connection] " + this.getRemoteAddress().toString(); + boolean isPlayerAddressLoggingEnabled = connection.server.getConfiguration() + .isPlayerAddressLoggingEnabled(); + String playerIp = + isPlayerAddressLoggingEnabled + ? this.getRemoteAddress().toString() : ""; + return "[legacy connection] " + playerIp; } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java index 2af8c3961..5a67dab30 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/InitialInboundConnection.java @@ -75,7 +75,12 @@ public final class InitialInboundConnection implements VelocityInboundConnection @Override public String toString() { - return "[initial connection] " + connection.getRemoteAddress().toString(); + boolean isPlayerAddressLoggingEnabled = connection.server.getConfiguration() + .isPlayerAddressLoggingEnabled(); + String playerIp = + isPlayerAddressLoggingEnabled + ? connection.getRemoteAddress().toString() : ""; + return "[initial connection] " + playerIp; } @Override