From e1f7b7b1263961f8494f1f0c70f6a3d09236b71f Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 27 Oct 2013 12:06:17 +1100 Subject: [PATCH] Add new ip forward method, must be manually enabled --- .../src/main/java/net/md_5/bungee/config/Configuration.java | 2 ++ .../main/java/net/md_5/bungee/connection/InitialHandler.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/proxy/src/main/java/net/md_5/bungee/config/Configuration.java b/proxy/src/main/java/net/md_5/bungee/config/Configuration.java index b1b8b816..df744d58 100644 --- a/proxy/src/main/java/net/md_5/bungee/config/Configuration.java +++ b/proxy/src/main/java/net/md_5/bungee/config/Configuration.java @@ -44,6 +44,7 @@ public class Configuration private int playerLimit = -1; private Collection disabledCommands; private int throttle = 4000; + private boolean ipFoward; public void load() { @@ -56,6 +57,7 @@ public class Configuration onlineMode = adapter.getBoolean( "online_mode", onlineMode ); playerLimit = adapter.getInt( "player_limit", playerLimit ); throttle = adapter.getInt( "connection_throttle", throttle ); + ipFoward = adapter.getBoolean( "ip_forward", ipFoward); disabledCommands = new CaseInsensitiveSet( (Collection) adapter.getList( "disabled_commands", Arrays.asList( "find" ) ) ); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 8190d6c8..1d0145ef 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -189,6 +189,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection this.vHost = new InetSocketAddress( handshake.getHost(), handshake.getPort() ); bungee.getLogger().log( Level.INFO, "{0} has connected", this ); + if ( BungeeCord.getInstance().config.isIpFoward() ) + { + handshake.setHost( handshake.getHost() + "\00" + getAddress().getHostString() ); + } + bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) ); switch ( handshake.getRequestedProtocol() )