2013-05-19 15:58:42 +08:00
From 391c4be8c84b3e1220a84b4878b2be67b143d62a Mon Sep 17 00:00:00 2001
2013-03-23 08:15:28 +08:00
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 11:15:11 +1100
Subject: [PATCH] BungeeCord Support
- Allows BungeeCord to set the players real IP address very early in the login process, so that the BungeeCord proxy IP is never even seen by a plugin.
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
2013-05-04 07:24:15 +08:00
index a945892..7ef9a6f 100644
2013-03-23 08:15:28 +08:00
--- a/src/main/java/net/minecraft/server/PendingConnection.java
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
2013-04-19 15:45:39 +08:00
@@ -221,4 +221,17 @@ public class PendingConnection extends Connection {
2013-03-23 08:15:28 +08:00
static boolean a(PendingConnection pendingconnection, boolean flag) {
return pendingconnection.h = flag;
}
+
+ // Spigot start
+ @Override
+ public void a(Packet250CustomPayload pcp) {
+ if (pcp.tag.equals("BungeeCord") && org.bukkit.craftbukkit.Spigot.bungeeIPs.contains(getSocket().getInetAddress().getHostAddress())) {
+ com.google.common.io.ByteArrayDataInput in = com.google.common.io.ByteStreams.newDataInput(pcp.data);
+ String subTag = in.readUTF();
+ if (subTag.equals("Login")) {
+ networkManager.setSocketAddress(new java.net.InetSocketAddress(in.readUTF(), in.readInt()));
+ }
+ }
+ }
+ // Spigot end
}
2013-04-25 07:42:40 +08:00
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
2013-05-04 07:24:15 +08:00
index 5ccc7f0..cc9c3ba 100644
2013-04-25 07:42:40 +08:00
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
2013-05-04 07:24:15 +08:00
@@ -293,7 +293,7 @@ public abstract class PlayerList {
2013-04-25 07:42:40 +08:00
// depending on the outcome.
EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, this.server.M() ? new DemoPlayerInteractManager(this.server.getWorldServer(0)) : new PlayerInteractManager(this.server.getWorldServer(0)));
Player player = entity.getBukkitEntity();
- PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, pendingconnection.getSocket().getInetAddress());
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) pendingconnection.networkManager.getSocketAddress()).getAddress()); // Spigot
SocketAddress socketaddress = pendingconnection.networkManager.getSocketAddress();
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
2013-05-04 07:24:15 +08:00
index fcd4136..fb4ec7b 100644
2013-04-25 07:42:40 +08:00
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
@@ -45,11 +45,11 @@ class ThreadLoginVerifier extends Thread {
return;
}
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), this.pendingConnection.getSocket().getInetAddress());
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), ((java.net.InetSocketAddress) this.pendingConnection.networkManager.getSocketAddress()).getAddress()); // Spigot
this.server.getPluginManager().callEvent(asyncEvent);
if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
- final PlayerPreLoginEvent event = new PlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), this.pendingConnection.getSocket().getInetAddress());
+ final PlayerPreLoginEvent event = new PlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), ((java.net.InetSocketAddress) this.pendingConnection.networkManager.getSocketAddress()).getAddress()); // Spigot
if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
}
2013-03-23 08:15:28 +08:00
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
2013-05-16 16:10:23 +08:00
index fed3181..a0c66d8 100644
2013-03-23 08:15:28 +08:00
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
2013-04-25 07:01:05 +08:00
@@ -54,6 +54,7 @@ public class Spigot {
2013-04-23 09:27:55 +08:00
private static boolean filterIps;
2013-03-23 08:15:28 +08:00
public static boolean tabPing = false;
private static Metrics metrics;
+ public static List<String> bungeeIPs;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
2013-05-16 16:10:23 +08:00
@@ -90,6 +91,7 @@ public class Spigot {
2013-03-23 08:15:28 +08:00
}
tabPing = configuration.getBoolean("settings.tab-ping", tabPing);
+ bungeeIPs = configuration.getStringList("settings.bungee-proxies");
if (metrics == null) {
try {
2013-05-14 19:14:43 +08:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2013-05-19 15:58:42 +08:00
index 0b5ea21..26cb661 100644
2013-05-14 19:14:43 +08:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1012,4 +1012,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.server.getScoreboardManager().setPlayerBoard(this, scoreboard);
}
+
+ // Spigot start
+ public InetSocketAddress getRawAddress() {
2013-05-19 15:58:42 +08:00
+ return (getHandle().playerConnection == null) ? null : (InetSocketAddress) getHandle().playerConnection.networkManager.getSocket().getRemoteSocketAddress();
2013-05-14 19:14:43 +08:00
+ }
+ // Spigot end
}
2013-03-23 08:15:28 +08:00
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
2013-05-16 16:10:23 +08:00
index 71374d7..f0d9129 100644
2013-03-23 08:15:28 +08:00
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
2013-04-23 09:50:42 +08:00
@@ -37,6 +37,8 @@ settings:
2013-03-23 08:15:28 +08:00
timeout-time: 30
restart-on-crash: false
restart-script-location: /path/to/server/start.sh
+ bungee-proxies:
+ - 127.0.0.1
world-settings:
default:
growth-chunks-per-tick: 650
--
2013-04-10 10:36:11 +08:00
1.8.2.1
2013-03-23 08:15:28 +08:00