From 14371a1a8c5e843007f96a1ab64a2b82c51e853e Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 5 Nov 2013 18:07:55 +1100 Subject: [PATCH] Don't rewrite the actual host packet, just a copy. --- proxy/src/main/java/net/md_5/bungee/ServerConnector.java | 9 ++++++++- .../java/net/md_5/bungee/connection/InitialHandler.java | 5 ----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index c1afb07c..67ac00ab 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -24,6 +24,7 @@ import net.md_5.bungee.protocol.MinecraftOutput; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.packet.EncryptionRequest; +import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.Login; import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.ScoreboardObjective; @@ -71,7 +72,13 @@ public class ServerConnector extends PacketHandler out.writeInt( user.getAddress().getPort() ); // channel.write( new PluginMessage( "BungeeCord", out.toByteArray() ) ); MOJANG - channel.write( user.getPendingConnection().getHandshake() ); + Handshake originalHandshake = user.getPendingConnection().getHandshake(); + Handshake copiedHandshake = new Handshake( originalHandshake.getProtocolVersion(), originalHandshake.getHost(), originalHandshake.getPort(), 2 ); + if ( BungeeCord.getInstance().config.isIpFoward() ) + { + copiedHandshake.setHost( copiedHandshake.getHost() + "\00" + user.getAddress().getHostString() ); + } + channel.write( copiedHandshake ); channel.setProtocol( Protocol.LOGIN ); channel.write( user.getPendingConnection().getLoginRequest() ); 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 76754ad7..3dc87f35 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 @@ -193,11 +193,6 @@ 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() )