#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 );
|
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)
|
public static byte[] readArray(ByteBuf buf)
|
||||||
{
|
{
|
||||||
return readArray( buf, buf.readableBytes() );
|
return readArray( buf, buf.readableBytes() );
|
||||||
|
@ -199,7 +199,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
|
|
||||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
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();
|
brand.release();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.md_5.bungee.connection;
|
package net.md_5.bungee.connection;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
@ -233,9 +234,12 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
||||||
String serverBrand = DefinedPacket.readString( brand );
|
String serverBrand = DefinedPacket.readString( brand );
|
||||||
brand.release();
|
brand.release();
|
||||||
|
|
||||||
|
Preconditions.checkState( !serverBrand.contains( bungee.getName() ), "Cannot connect proxy to itself!" );
|
||||||
|
|
||||||
brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand, brand );
|
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand, brand );
|
||||||
pluginMessage.setData( DefinedPacket.readArray( brand ) );
|
pluginMessage.setData( DefinedPacket.toArray( brand ) );
|
||||||
brand.release();
|
brand.release();
|
||||||
// changes in the packet are ignored so we need to send it manually
|
// changes in the packet are ignored so we need to send it manually
|
||||||
con.unsafe().sendPacket( pluginMessage );
|
con.unsafe().sendPacket( pluginMessage );
|
||||||
|
Loading…
Reference in New Issue
Block a user