2016-08-26 11:05:00 +02:00
|
|
|
From f85163140995e0bdf5992b0c1993a01ce63aa571 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
|
|
|
|
Subject: [PATCH] Upgrade to netty 4.1
|
|
|
|
|
|
|
|
Don't access a ByteBuf's underlying array with ByteBuf.array()
|
|
|
|
- ByteBuf.array() returns the underlying array storage, and does *not* return a view of the buffer as an array
|
|
|
|
|
|
|
|
diff --git a/pom.xml b/pom.xml
|
2016-07-31 20:02:30 +02:00
|
|
|
index 3319e60..858d367 100644
|
2016-05-28 18:34:39 +02:00
|
|
|
--- a/pom.xml
|
|
|
|
+++ b/pom.xml
|
2016-07-17 03:12:39 +02:00
|
|
|
@@ -83,7 +83,7 @@
|
2016-05-28 18:34:39 +02:00
|
|
|
|
|
|
|
<properties>
|
|
|
|
<build.number>unknown</build.number>
|
2016-07-31 19:59:19 +02:00
|
|
|
- <netty.version>4.0.40.Final</netty.version>
|
2016-07-31 20:02:30 +02:00
|
|
|
+ <netty.version>4.1.4.Final</netty.version>
|
2016-05-28 18:34:39 +02:00
|
|
|
<!-- Require Java 8 -->
|
|
|
|
<maven.compiler.source>1.8</maven.compiler.source>
|
|
|
|
<maven.compiler.target>1.8</maven.compiler.target>
|
|
|
|
diff --git a/protocol/pom.xml b/protocol/pom.xml
|
2016-06-09 08:08:37 +02:00
|
|
|
index 7a74143..58e107e 100644
|
2016-05-28 18:34:39 +02:00
|
|
|
--- a/protocol/pom.xml
|
|
|
|
+++ b/protocol/pom.xml
|
|
|
|
@@ -32,6 +32,12 @@
|
|
|
|
<scope>compile</scope>
|
|
|
|
</dependency>
|
|
|
|
<dependency>
|
|
|
|
+ <groupId>io.netty</groupId>
|
|
|
|
+ <artifactId>netty-handler</artifactId>
|
|
|
|
+ <version>${netty.version}</version>
|
|
|
|
+ <scope>compile</scope>
|
|
|
|
+ </dependency>
|
|
|
|
+ <dependency>
|
|
|
|
<groupId>net.sf.trove4j</groupId>
|
|
|
|
<artifactId>trove4j</artifactId>
|
|
|
|
<version>3.0.3</version>
|
|
|
|
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
|
2016-08-26 11:05:00 +02:00
|
|
|
index 6dcdece..e67773d 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
|
2016-08-26 11:05:00 +02:00
|
|
|
@@ -2,6 +2,7 @@ package net.md_5.bungee.protocol.packet;
|
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:12:37 +02:00
|
|
|
+import io.netty.buffer.ByteBufUtil;
|
2016-08-20 22:34:49 +02:00
|
|
|
import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import java.io.ByteArrayInputStream;
|
2016-08-26 11:05:00 +02:00
|
|
|
@@ -29,10 +30,23 @@ public class PluginMessage extends DefinedPacket
|
|
|
|
return input.getTag().equals( "REGISTER" ) || input.getTag().equals( "MC|Brand" );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
- //
|
|
|
|
+
|
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
|
2016-08-26 11:05:00 +02:00
|
|
|
index e599e7e..ccdcf82 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
|
2016-08-26 11:05:00 +02:00
|
|
|
@@ -198,7 +198,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 );
|
2016-08-20 22:12:37 +02:00
|
|
|
- user.unsafe().sendPacket( new PluginMessage( "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) );
|
2016-05-28 18:34:39 +02:00
|
|
|
+ user.unsafe().sendPacket( new PluginMessage( "MC|Brand", brand, handshakeHandler.isServerForge() ) );
|
|
|
|
brand.release();
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
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
|
2016-08-20 22:12:37 +02:00
|
|
|
index 288d602..c7e75bf 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
|
2016-08-20 22:12:37 +02:00
|
|
|
@@ -239,7 +239,7 @@ public class DownstreamBridge extends PacketHandler
|
|
|
|
|
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
|
2016-05-31 19:48:53 +02:00
|
|
|
index 621a06c..0ec3f81 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
|
|
|
|
@@ -41,9 +41,9 @@ import net.md_5.bungee.protocol.Varint21LengthFieldPrepender;
|
|
|
|
public class PipelineUtils
|
|
|
|
{
|
|
|
|
|
|
|
|
- public static final AttributeKey<ListenerInfo> LISTENER = new AttributeKey<>( "ListerInfo" );
|
|
|
|
- public static final AttributeKey<UserConnection> USER = new AttributeKey<>( "User" );
|
|
|
|
- public static final AttributeKey<BungeeServerInfo> TARGET = new AttributeKey<>( "Target" );
|
|
|
|
+ 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
|
|
|
|
--
|
2016-08-26 11:05:00 +02:00
|
|
|
2.7.4
|
2016-05-28 18:34:39 +02:00
|
|
|
|