13
0
geforkt von Mirrors/Paper

Updated Upstream (Spigot) (#5550)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Spigot Changes:
4225eac0 SPIGOT-6423: Improve IP forwarding
Dieser Commit ist enthalten in:
Jake Potrebic 2021-04-27 16:38:35 -07:00
Ursprung 516a8cf544
Commit 8fb1ea9e2d
3 geänderte Dateien mit 8 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,9 @@
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] Validate bungee forwarded hostname
Subject: [PATCH] Add bypass host check
Paper.bypassHostCheck
Seriously, fix your firewalls. -.-
@ -9,15 +11,6 @@ diff --git a/src/main/java/net/minecraft/server/network/HandshakeListener.java b
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/network/HandshakeListener.java
@@ -0,0 +0,0 @@
package net.minecraft.server.network;
+import com.google.common.net.InetAddresses;
+import com.google.common.net.InternetDomainName;
+
import net.minecraft.SharedConstants;
import net.minecraft.network.EnumProtocol;
import net.minecraft.network.NetworkManager;
@@ -0,0 +0,0 @@ public class HandshakeListener implements PacketHandshakingInListener {
private static final IChatBaseComponent a = new ChatComponentText("Ignoring status request");
private final MinecraftServer b;
@ -27,29 +20,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public HandshakeListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
this.b = minecraftserver;
@@ -0,0 +0,0 @@ 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 ) {
+ // Paper start
+ if (!BYPASS_HOSTCHECK && !validate(split[1])) {
+ final ChatMessage message = new ChatMessage("Invalid hostname");
+ this.getNetworkManager().sendPacket(new PacketLoginOutDisconnect(message));
+ this.getNetworkManager().close(message);
+ return;
+ }
+ // Paper end
- 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] );
@@ -0,0 +0,0 @@ public class HandshakeListener implements PacketHandshakingInListener {
public NetworkManager a() {
return this.c;
}
+
+ // Paper start - https://stackoverflow.com/questions/9954140/check-if-a-string-is-a-hostname-or-an-ip-address-in-java
+ public static boolean validate(final String hostname) {
+ //noinspection UnstableApiUsage
+ return InetAddresses.isUriInetAddress(hostname);
+ }
+ // Paper end
}

Datei anzeigen

@ -52,5 +52,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if (org.spigotmc.SpigotConfig.bungee) {
+ //if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
String[] split = packethandshakinginsetprotocol.hostname.split("\00");
if ( split.length == 3 || split.length == 4 ) {
if ( ( split.length == 3 || split.length == 4 ) && ( HOST_PATTERN.matcher( split[1] ).matches() ) ) {
packethandshakinginsetprotocol.hostname = split[0];

@ -1 +1 @@
Subproject commit a25e8ed26cbca903b4d6ee3823d1b9f4f5d06cc3
Subproject commit 4225eac084af31c8b9dca9eed3f7d146f3bc3625