PaperMC/patches/server-unmapped/0703-Add-bypass-host-check.patch
2021-06-11 14:02:28 +02:00

30 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 18 Apr 2021 21:27:01 +0100
Subject: [PATCH] Add bypass host check
Paper.bypassHostCheck
Seriously, fix your firewalls. -.-
diff --git a/src/main/java/net/minecraft/server/network/HandshakeListener.java b/src/main/java/net/minecraft/server/network/HandshakeListener.java
index 26fe1f612e9dab37e5bf6bc431eb362bd7e4803a..74006c0af831c0e6a2b84b3638e397ab54984dc5 100644
--- a/src/main/java/net/minecraft/server/network/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/network/HandshakeListener.java
@@ -30,6 +30,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
private static final IChatBaseComponent a = new ChatComponentText("Ignoring status request");
private final MinecraftServer b;
private final NetworkManager c; final NetworkManager getNetworkManager() { return this.c; } // Paper - OBFHELPER
+ private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper
public HandshakeListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
this.b = minecraftserver;
@@ -118,7 +119,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
// Spigot Start
//if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
String[] split = packethandshakinginsetprotocol.hostname.split("\00");
- if ( ( split.length == 3 || split.length == 4 ) && ( HOST_PATTERN.matcher( split[1] ).matches() ) ) {
+ if ( ( split.length == 3 || split.length == 4 ) && ( BYPASS_HOSTCHECK || HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper
packethandshakinginsetprotocol.hostname = split[0];
c.socketAddress = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) c.getSocketAddress()).getPort());
c.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] );