From 635832cc399da1e81e414409ddea4e1405bcbbb0 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 18 Apr 2021 21:27:01 +0100 Subject: [PATCH] Add bypass host check Paper.bypassHostCheck Seriously, fix your firewalls. -.- --- .../ServerHandshakePacketListenerImpl.java.patch | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch index 22432bc451..25f0c29b33 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -@@ -13,8 +13,22 @@ +@@ -13,11 +13,26 @@ import net.minecraft.network.protocol.status.StatusProtocols; import net.minecraft.server.MinecraftServer; @@ -23,7 +23,11 @@ private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request"); private final MinecraftServer server; private final Connection connection; -@@ -26,6 +40,7 @@ ++ private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper + + public ServerHandshakePacketListenerImpl(MinecraftServer server, Connection connection) { + this.server = server; +@@ -26,6 +41,7 @@ @Override public void handleIntention(ClientIntentionPacket packet) { @@ -31,7 +35,7 @@ switch (packet.intention()) { case LOGIN: this.beginLogin(packet, false); -@@ -55,23 +70,122 @@ +@@ -55,23 +71,122 @@ throw new UnsupportedOperationException("Invalid intention " + String.valueOf(packet.intention())); } @@ -133,7 +137,7 @@ + String[] split = packet.hostName().split("\00"); + if (!handledByEvent && proxyLogicEnabled) { // Paper + // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above! -+ if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { ++ if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper - Add bypass host check + this.connection.hostname = split[0]; + this.connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort()); + this.connection.spoofedUUID = com.mojang.util.UndashedUuid.fromStringLenient( split[2] );