mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-24 17:47:41 +01:00
#1939: Fix server brand; prevent bungee-bungee connections.
This commit is contained in:
parent
11c7b246e0
commit
504d3c0529
@ -48,6 +48,14 @@ public abstract class DefinedPacket
|
||||
buf.writeBytes( b );
|
||||
}
|
||||
|
||||
public static byte[] toArray(ByteBuf buf)
|
||||
{
|
||||
byte[] ret = new byte[ buf.readableBytes() ];
|
||||
buf.readBytes( ret );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static byte[] readArray(ByteBuf buf)
|
||||
{
|
||||
return readArray( buf, buf.readableBytes() );
|
||||
|
@ -199,7 +199,7 @@ public class ServerConnector extends PacketHandler
|
||||
|
||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
||||
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", DefinedPacket.readArray( brand ), handshakeHandler.isServerForge() ) );
|
||||
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) );
|
||||
brand.release();
|
||||
} else
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import java.io.DataInput;
|
||||
@ -233,9 +234,12 @@ public class DownstreamBridge extends PacketHandler
|
||||
ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
||||
String serverBrand = DefinedPacket.readString( brand );
|
||||
brand.release();
|
||||
|
||||
Preconditions.checkState( !serverBrand.contains( bungee.getName() ), "Cannot connect proxy to itself!" );
|
||||
|
||||
brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand, brand );
|
||||
pluginMessage.setData( DefinedPacket.readArray( brand ) );
|
||||
pluginMessage.setData( DefinedPacket.toArray( brand ) );
|
||||
brand.release();
|
||||
// changes in the packet are ignored so we need to send it manually
|
||||
con.unsafe().sendPacket( pluginMessage );
|
||||
|
Loading…
Reference in New Issue
Block a user