2023-11-07 12:47:27 +01:00
|
|
|
From de632d241ae895ad859c98bf12954a4c092f3b62 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
|
2022-03-21 15:08:26 +01:00
|
|
|
index 70b292f0..91f71c09 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
|
2021-11-12 20:47:23 +01:00
|
|
|
@@ -3,6 +3,7 @@ package net.md_5.bungee.protocol.packet;
|
|
|
|
import com.google.common.base.Function;
|
2016-08-20 22:12:37 +02:00
|
|
|
import com.google.common.base.Preconditions;
|
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;
|
2021-11-12 20:47:23 +01:00
|
|
|
@@ -47,10 +48,23 @@ public class PluginMessage extends DefinedPacket
|
|
|
|
return "legacy:" + tag.toLowerCase( Locale.ROOT );
|
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
|
2023-11-07 12:47:27 +01:00
|
|
|
index 6d660bab..137d93cb 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
|
2023-11-07 12:47:27 +01:00
|
|
|
@@ -267,7 +267,7 @@ public class ServerConnector extends PacketHandler
|
2023-09-21 12:33:23 +02:00
|
|
|
|
2020-06-28 05:39:33 +02:00
|
|
|
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
|
|
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
2023-09-21 12:33:23 +02:00
|
|
|
- user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler != null && handshakeHandler.isServerForge() ) );
|
|
|
|
+ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler != null && handshakeHandler.isServerForge() ) ); // Waterfall
|
2020-06-28 05:39:33 +02:00
|
|
|
brand.release();
|
|
|
|
}
|
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
|
2023-11-07 12:47:27 +01:00
|
|
|
index 172cc8e5..a16c48bb 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
|
2023-09-21 12:33:23 +02:00
|
|
|
@@ -300,7 +300,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
|
2023-03-25 19:36:07 +01:00
|
|
|
index 5b9c35d1..2d6885a9 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
|
2023-03-25 19:36:07 +01:00
|
|
|
@@ -50,7 +50,7 @@ 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" );
|
2022-03-21 15:08:26 +01:00
|
|
|
+ public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.newInstance( "ListerInfo" );
|
2016-05-28 18:34:39 +02:00
|
|
|
public static final ChannelInitializer<Channel> SERVER_CHILD = new ChannelInitializer<Channel>()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
--
|
2023-11-07 12:47:27 +01:00
|
|
|
2.42.1
|
2016-05-28 18:34:39 +02:00
|
|
|
|