2016-03-02 21:28:13 +00:00
|
|
|
From abc10e573e1f4f0c7d755ef8d96a1e4aa1381c17 Mon Sep 17 00:00:00 2001
|
2014-07-21 20:46:54 +00:00
|
|
|
From: md_5 <md_5@live.com.au>
|
|
|
|
Date: Sun, 1 Dec 2013 18:18:41 +1100
|
|
|
|
Subject: [PATCH] BungeeCord Support
|
|
|
|
|
|
|
|
Provides support for IP forwarding via BungeeCord.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
|
2016-03-01 00:23:45 +00:00
|
|
|
index ee987b9..ed20034 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
|
2015-02-28 11:36:22 +00:00
|
|
|
@@ -7,6 +7,7 @@ import java.util.HashMap;
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
public class HandshakeListener implements PacketHandshakingInListener {
|
2015-02-28 11:36:22 +00:00
|
|
|
|
2014-07-21 20:46:54 +00:00
|
|
|
+ private static final com.google.gson.Gson gson = new com.google.gson.Gson(); // Spigot
|
|
|
|
// CraftBukkit start - add fields
|
|
|
|
private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
|
|
|
|
private static int throttleCounter = 0;
|
2014-11-28 01:17:45 +00:00
|
|
|
@@ -71,6 +72,26 @@ public class HandshakeListener implements PacketHandshakingInListener {
|
2014-07-21 20:46:54 +00:00
|
|
|
this.b.close(chatcomponenttext);
|
|
|
|
} else {
|
2016-02-29 21:33:06 +00:00
|
|
|
this.b.setPacketListener(new LoginListener(this.a, this.b));
|
2014-07-21 20:46:54 +00:00
|
|
|
+ // Spigot Start
|
|
|
|
+ if (org.spigotmc.SpigotConfig.bungee) {
|
2015-07-30 07:22:16 +00:00
|
|
|
+ String[] split = packethandshakinginsetprotocol.hostname.split("\00");
|
2014-07-21 20:46:54 +00:00
|
|
|
+ if ( split.length == 3 || split.length == 4 ) {
|
2015-07-30 07:22:16 +00:00
|
|
|
+ packethandshakinginsetprotocol.hostname = split[0];
|
2015-02-28 11:36:22 +00:00
|
|
|
+ b.l = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) b.getSocketAddress()).getPort());
|
2014-11-28 01:17:45 +00:00
|
|
|
+ b.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] );
|
2014-07-21 20:46:54 +00:00
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ chatcomponenttext = new ChatComponentText("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
|
2016-02-29 21:33:06 +00:00
|
|
|
+ this.b.sendPacket(new PacketLoginOutDisconnect(chatcomponenttext));
|
2014-07-21 20:46:54 +00:00
|
|
|
+ this.b.close(chatcomponenttext);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if ( split.length == 4 )
|
|
|
|
+ {
|
2014-11-28 01:17:45 +00:00
|
|
|
+ b.spoofedProfile = gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class);
|
2014-07-21 20:46:54 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Spigot End
|
2016-02-29 21:33:06 +00:00
|
|
|
((LoginListener) this.b.i()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 71d24b2..efa785f 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -84,9 +84,24 @@ public class LoginListener implements PacketLoginInListener, ITickable {
|
2014-07-21 20:46:54 +00:00
|
|
|
// Spigot start
|
|
|
|
public void initUUID()
|
|
|
|
{
|
|
|
|
- UUID uuid = UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + this.i.getName() ).getBytes( Charsets.UTF_8 ) );
|
|
|
|
+ UUID uuid;
|
|
|
|
+ if ( networkManager.spoofedUUID != null )
|
|
|
|
+ {
|
|
|
|
+ uuid = networkManager.spoofedUUID;
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ uuid = UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + this.i.getName() ).getBytes( Charsets.UTF_8 ) );
|
|
|
|
+ }
|
|
|
|
|
|
|
|
this.i = new GameProfile( uuid, this.i.getName() );
|
|
|
|
+
|
|
|
|
+ if (networkManager.spoofedProfile != null)
|
|
|
|
+ {
|
2014-11-28 01:17:45 +00:00
|
|
|
+ for ( com.mojang.authlib.properties.Property property : networkManager.spoofedProfile )
|
2014-07-21 20:46:54 +00:00
|
|
|
+ {
|
|
|
|
+ this.i.getProperties().put( property.getName(), property );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
// Spigot end
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 5ed2c96..c3ff6c2 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -64,7 +64,11 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
2015-02-28 11:36:22 +00:00
|
|
|
private final Queue<NetworkManager.QueuedPacket> i = Queues.newConcurrentLinkedQueue();
|
|
|
|
private final ReentrantReadWriteLock j = new ReentrantReadWriteLock();
|
2015-06-06 09:47:02 +00:00
|
|
|
public Channel channel;
|
2015-02-28 11:36:22 +00:00
|
|
|
- private SocketAddress l;
|
2015-06-06 09:47:02 +00:00
|
|
|
+ // Spigot Start // PAIL
|
2015-02-28 11:36:22 +00:00
|
|
|
+ public SocketAddress l;
|
2014-07-21 20:46:54 +00:00
|
|
|
+ public java.util.UUID spoofedUUID;
|
2014-11-28 01:17:45 +00:00
|
|
|
+ public com.mojang.authlib.properties.Property[] spoofedProfile;
|
2014-07-21 20:46:54 +00:00
|
|
|
+ // Spigot End
|
2015-02-28 11:36:22 +00:00
|
|
|
private PacketListener m;
|
|
|
|
private IChatBaseComponent n;
|
|
|
|
private boolean o;
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -323,4 +327,11 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
2015-02-28 11:36:22 +00:00
|
|
|
this.b = agenericfuturelistener;
|
|
|
|
}
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Spigot Start
|
|
|
|
+ public SocketAddress getRawAddress()
|
|
|
|
+ {
|
2015-05-09 20:23:26 +00:00
|
|
|
+ return this.channel.remoteAddress();
|
2014-07-21 20:46:54 +00:00
|
|
|
+ }
|
|
|
|
+ // Spigot End
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java b/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 86f1be7..e6ab607 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java
|
2015-02-28 11:36:22 +00:00
|
|
|
@@ -13,7 +13,7 @@ public class PacketHandshakingInSetProtocol implements Packet<PacketHandshakingI
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2015-02-28 11:36:22 +00:00
|
|
|
public void a(PacketDataSerializer packetdataserializer) throws IOException {
|
2016-02-29 21:33:06 +00:00
|
|
|
this.a = packetdataserializer.g();
|
2015-07-30 07:22:16 +00:00
|
|
|
- this.hostname = packetdataserializer.c(255);
|
|
|
|
+ this.hostname = packetdataserializer.c(Short.MAX_VALUE); // Spigot
|
|
|
|
this.port = packetdataserializer.readUnsignedShort();
|
2016-02-29 21:33:06 +00:00
|
|
|
this.d = EnumProtocol.a(packetdataserializer.g());
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index f878dfc..eb9375d 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -451,7 +451,7 @@ public abstract class PlayerList {
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), gameprofile, new PlayerInteractManager(server.getWorldServer(0)));
|
2014-07-21 20:46:54 +00:00
|
|
|
Player player = entity.getBukkitEntity();
|
|
|
|
- PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
|
|
|
|
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.networkManager.getRawAddress()).getAddress());
|
|
|
|
String s;
|
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) {
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 72e1e2f..1a5f14d 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -560,7 +560,13 @@ public final class CraftServer implements Server {
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getConnectionThrottle() {
|
|
|
|
- return this.configuration.getInt("settings.connection-throttle");
|
|
|
|
+ // Spigot Start - Automatically set connection throttle for bungee configurations
|
|
|
|
+ if (org.spigotmc.SpigotConfig.bungee) {
|
|
|
|
+ return -1;
|
|
|
|
+ } else {
|
|
|
|
+ return this.configuration.getInt("settings.connection-throttle");
|
|
|
|
+ }
|
|
|
|
+ // Spigot End
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2016-03-02 21:28:13 +00:00
|
|
|
index d245755..71d4ddc 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2016-03-02 21:28:13 +00:00
|
|
|
@@ -1409,6 +1409,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2014-07-21 20:46:54 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
+ public InetSocketAddress getRawAddress()
|
|
|
|
+ {
|
|
|
|
+ return (InetSocketAddress) getHandle().playerConnection.networkManager.getRawAddress();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
public boolean getCollidesWithEntities()
|
|
|
|
{
|
|
|
|
return getHandle().collidesWithEntities;
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
2015-05-25 19:09:58 +00:00
|
|
|
index 34def7b..824ba7a 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
2015-05-25 19:09:58 +00:00
|
|
|
@@ -211,4 +211,14 @@ public class SpigotConfig
|
2014-07-21 20:46:54 +00:00
|
|
|
commands.put( "restart", new RestartCommand( "restart" ) );
|
|
|
|
WatchdogThread.doStart( timeoutTime, restartOnCrash );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public static boolean bungee;
|
|
|
|
+ private static void bungee() {
|
|
|
|
+ if ( version < 4 )
|
|
|
|
+ {
|
|
|
|
+ set( "settings.bungeecord", false );
|
|
|
|
+ System.out.println( "Oudated config, disabling BungeeCord support!" );
|
|
|
|
+ }
|
|
|
|
+ bungee = getBoolean( "settings.bungeecord", false );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2016-02-29 21:33:06 +00:00
|
|
|
2.5.0
|
2014-07-21 20:46:54 +00:00
|
|
|
|