summaryrefslogtreecommitdiffhomepage
path: root/patches/server/0519-Add-bypass-host-check.patch
blob: d6c893d808567c8cf334927b6c88c80c952c77ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
index ffe3048d16809b177d2fb495a25a16ed78b50e6b..b5d8ef9dd24687b99f5cf547574351c359fb85ba 100644
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
@@ -31,6 +31,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
     private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request");
     private final MinecraftServer server;
     private final Connection connection;
+    private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper
 
     public ServerHandshakePacketListenerImpl(MinecraftServer server, Connection connection) {
         this.server = server;
@@ -163,7 +164,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
             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] );