2019-04-23 10:09:26 +02:00
|
|
|
From 911d768f6c07714cbc4bed0d12b5df5bc8e0fdbb Mon Sep 17 00:00:00 2001
|
2016-05-28 18:34:39 +02:00
|
|
|
From: Techcable <Techcable@techcable.net>
|
|
|
|
Date: Tue, 3 May 2016 20:31:52 -0700
|
2016-12-04 18:31:55 +01:00
|
|
|
Subject: [PATCH] Don't access a ByteBuf's underlying array
|
2016-08-30 19:30:38 +02:00
|
|
|
|
2016-12-04 18:31:55 +01:00
|
|
|
It returns the underlying array storage, and does *not* return a view of the buffer as an array
|
2016-05-28 18:34:39 +02:00
|
|
|
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
2019-04-23 10:09:26 +02:00
|
|
|
index c01cf317..17e12655 100644
|
2016-05-28 18:34:39 +02:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
2019-04-23 10:09:26 +02:00
|
|
|
@@ -4,6 +4,7 @@ import com.google.common.base.Function;
|
2016-08-20 22:12:37 +02:00
|
|
|
import com.google.common.base.Preconditions;
|
2016-08-26 11:05:00 +02:00
|
|
|
import com.google.common.base.Predicate;
|
2016-08-20 22:34:49 +02:00
|
|
|
import io.netty.buffer.ByteBuf;
|
2019-04-23 10:09:26 +02:00
|
|
|
+import io.netty.buffer.ByteBufUtil; // Waterfall
|
2016-08-20 22:34:49 +02:00
|
|
|
import java.io.ByteArrayInputStream;
|
2019-04-23 10:09:26 +02:00
|
|
|
import java.io.DataInput;
|
|
|
|
import java.io.DataInputStream;
|
2018-07-15 12:58:44 +02:00
|
|
|
@@ -56,10 +57,23 @@ public class PluginMessage extends DefinedPacket
|
|
|
|
return ( input.getTag().equals( "REGISTER" ) || input.getTag().equals( "minecraft:register" ) || input.getTag().equals( "MC|Brand" ) || input.getTag().equals( "minecraft:brand" ) ) && input.getData().length < Byte.MAX_VALUE;
|
2016-08-26 11:05:00 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
- //
|
|
|
|
+
|
2016-05-28 18:34:39 +02:00
|
|
|
+ public PluginMessage(String tag, ByteBuf data, boolean allowExtendedPacket) {
|
|
|
|
+ this(tag, ByteBufUtil.getBytes(data), allowExtendedPacket);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
private String tag;
|
|
|
|
private byte[] data;
|
|
|
|
|
|
|
|
+ public void setData(byte[] data) {
|
|
|
|
+ this.data = Preconditions.checkNotNull(data, "Null data");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setData(ByteBuf buf) {
|
|
|
|
+ Preconditions.checkNotNull(buf, "Null buffer");
|
|
|
|
+ setData(ByteBufUtil.getBytes(buf));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* Allow this packet to be sent as an "extended" packet.
|
|
|
|
*/
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
2019-04-23 10:09:26 +02:00
|
|
|
index fb2d9e27..d1ae05b3 100644
|
2016-05-28 18:34:39 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
2018-12-21 16:24:26 +01:00
|
|
|
@@ -216,7 +216,7 @@ public class ServerConnector extends PacketHandler
|
2016-05-28 18:34:39 +02:00
|
|
|
|
|
|
|
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
|
|
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
2018-07-15 12:58:44 +02:00
|
|
|
- user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) );
|
|
|
|
+ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) );
|
2016-05-28 18:34:39 +02:00
|
|
|
brand.release();
|
2016-10-30 15:46:05 +01:00
|
|
|
|
|
|
|
user.setDimension( login.getDimension() );
|
2016-05-28 18:34:39 +02:00
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
2019-04-23 10:09:26 +02:00
|
|
|
index 63162de0..db39f52d 100644
|
2016-05-28 18:34:39 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
2019-04-23 10:09:26 +02:00
|
|
|
@@ -256,7 +256,7 @@ public class DownstreamBridge extends PacketHandler
|
2016-08-20 22:12:37 +02:00
|
|
|
|
2016-05-28 18:34:39 +02:00
|
|
|
brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
|
|
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand, brand );
|
2016-08-20 22:12:37 +02:00
|
|
|
- pluginMessage.setData( DefinedPacket.toArray( brand ) );
|
2016-05-28 18:34:39 +02:00
|
|
|
+ pluginMessage.setData( brand );
|
|
|
|
brand.release();
|
|
|
|
// changes in the packet are ignored so we need to send it manually
|
|
|
|
con.unsafe().sendPacket( pluginMessage );
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
2019-04-23 10:09:26 +02:00
|
|
|
index f75ec97d..bc7a6d80 100644
|
2016-05-28 18:34:39 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
2018-12-27 00:40:37 +01:00
|
|
|
@@ -43,9 +43,9 @@ import net.md_5.bungee.protocol.Varint21LengthFieldPrepender;
|
2016-05-28 18:34:39 +02:00
|
|
|
public class PipelineUtils
|
|
|
|
{
|
|
|
|
|
2016-08-30 19:30:38 +02:00
|
|
|
- public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.valueOf( "ListerInfo" );
|
|
|
|
- public static final AttributeKey<UserConnection> USER = AttributeKey.valueOf( "User" );
|
|
|
|
- public static final AttributeKey<BungeeServerInfo> TARGET = AttributeKey.valueOf( "Target" );
|
2016-05-28 18:34:39 +02:00
|
|
|
+ public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.newInstance("ListerInfo");
|
|
|
|
+ public static final AttributeKey<UserConnection> USER = AttributeKey.newInstance("User");
|
|
|
|
+ public static final AttributeKey<BungeeServerInfo> TARGET = AttributeKey.newInstance("Target");
|
|
|
|
public static final ChannelInitializer<Channel> SERVER_CHILD = new ChannelInitializer<Channel>()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
--
|
2019-04-23 10:09:26 +02:00
|
|
|
2.21.0
|
2016-05-28 18:34:39 +02:00
|
|
|
|