2019-04-23 10:09:26 +02:00
|
|
|
From 59cd643646283aa72acf873abea280d7c59ceeba Mon Sep 17 00:00:00 2001
|
2018-10-14 11:47:38 +02:00
|
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
|
|
Date: Fri, 12 Oct 2018 14:28:52 +0100
|
|
|
|
Subject: [PATCH] Add Configuration to allow empty packets
|
|
|
|
|
|
|
|
This setting provides the ability to allow servers/clients
|
|
|
|
to send empty packets without kicking the player with an error.
|
|
|
|
|
|
|
|
This option is not encouraged or supported in any capacity, and is
|
|
|
|
provided as a last ditch effort for server owners to allow players
|
|
|
|
to connect in such a broken state as allowed by vanilla.
|
|
|
|
|
|
|
|
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
2019-04-23 10:09:26 +02:00
|
|
|
index 058cca67..46adc983 100644
|
2018-10-14 11:47:38 +02:00
|
|
|
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
|
|
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
2019-04-23 10:09:26 +02:00
|
|
|
@@ -207,4 +207,11 @@ public interface ProxyConfig
|
2018-10-14 11:47:38 +02:00
|
|
|
* @return should we disable the tab completion limit for 1.13+ clients
|
|
|
|
*/
|
|
|
|
boolean isDisableModernTabLimiter();
|
|
|
|
+
|
2019-03-30 17:09:06 +01:00
|
|
|
+ /**
|
|
|
|
+ * Should we allow empty packets
|
|
|
|
+ *
|
|
|
|
+ * @return should we allow empty packets
|
|
|
|
+ */
|
2018-10-14 11:47:38 +02:00
|
|
|
+ boolean isAllowEmptyPackets();
|
|
|
|
}
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
2019-04-23 10:09:26 +02:00
|
|
|
index e903fd09..98a54601 100644
|
2018-10-14 11:47:38 +02:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
2019-04-23 10:09:26 +02:00
|
|
|
@@ -11,6 +11,13 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
2018-10-14 11:47:38 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
private static boolean DIRECT_WARNING;
|
|
|
|
+ // Waterfall start
|
|
|
|
+ private boolean allowEmptyPackets;
|
|
|
|
+
|
|
|
|
+ public Varint21FrameDecoder(boolean allowEmptyPackets) {
|
|
|
|
+ this.allowEmptyPackets = allowEmptyPackets;
|
|
|
|
+ }
|
|
|
|
+ // Waterfall end
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
|
2019-04-23 10:09:26 +02:00
|
|
|
@@ -30,7 +37,7 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
2018-10-14 11:47:38 +02:00
|
|
|
if ( buf[i] >= 0 )
|
|
|
|
{
|
|
|
|
int length = DefinedPacket.readVarInt( Unpooled.wrappedBuffer( buf ) );
|
|
|
|
- if ( length == 0 )
|
|
|
|
+ if ( length == 0 && !allowEmptyPackets) // Waterfall
|
|
|
|
{
|
|
|
|
throw new CorruptedFrameException( "Empty Packet!" );
|
|
|
|
}
|
|
|
|
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
2019-03-30 19:01:17 +01:00
|
|
|
index 4ff8da6d..f28f0111 100644
|
2018-10-14 11:47:38 +02:00
|
|
|
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
|
|
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
2019-03-30 19:01:17 +01:00
|
|
|
@@ -42,6 +42,17 @@ public class WaterfallConfiguration extends Configuration {
|
2018-10-14 11:47:38 +02:00
|
|
|
private int tabThrottle = 1000;
|
|
|
|
private boolean disableModernTabLimiter = true;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * This setting provides the ability to allow servers/clients
|
|
|
|
+ * to send empty packets without kicking the player with an error.
|
|
|
|
+ *
|
|
|
|
+ * This option is not encouraged or supported in any capacity, and is
|
|
|
|
+ * provided as a last ditch effort for server owners to allow players
|
|
|
|
+ * to connect in such a broken state as allowed by vanilla.
|
|
|
|
+ */
|
|
|
|
+ private boolean allowEmptyPackets = false;
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void load() {
|
|
|
|
super.load();
|
2019-03-30 19:01:17 +01:00
|
|
|
@@ -53,6 +64,7 @@ public class WaterfallConfiguration extends Configuration {
|
2018-10-14 11:47:38 +02:00
|
|
|
// Throttling options
|
|
|
|
tabThrottle = config.getInt("throttling.tab_complete", tabThrottle);
|
|
|
|
disableModernTabLimiter = config.getBoolean("disable_modern_tab_limiter", disableModernTabLimiter);
|
|
|
|
+ allowEmptyPackets = config.getBoolean("allow_empty_packets", allowEmptyPackets);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-03-30 19:01:17 +01:00
|
|
|
@@ -79,4 +91,9 @@ public class WaterfallConfiguration extends Configuration {
|
2018-10-14 11:47:38 +02:00
|
|
|
public boolean isDisableModernTabLimiter() {
|
|
|
|
return disableModernTabLimiter;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isAllowEmptyPackets() {
|
2019-03-06 16:35:52 +01:00
|
|
|
+ return allowEmptyPackets;
|
2018-10-14 11:47:38 +02:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
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 23241d68..051430ce 100644
|
2018-10-14 11:47:38 +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
|
|
|
@@ -146,7 +146,7 @@ public class PipelineUtils
|
2018-10-14 11:47:38 +02:00
|
|
|
ch.config().setWriteBufferWaterMark( MARK );
|
|
|
|
|
|
|
|
ch.pipeline().addLast( TIMEOUT_HANDLER, new ReadTimeoutHandler( BungeeCord.getInstance().config.getTimeout(), TimeUnit.MILLISECONDS ) );
|
|
|
|
- ch.pipeline().addLast( FRAME_DECODER, new Varint21FrameDecoder() );
|
|
|
|
+ ch.pipeline().addLast( FRAME_DECODER, new Varint21FrameDecoder( BungeeCord.getInstance().getConfig().isAllowEmptyPackets()) ); // Waterfall
|
|
|
|
ch.pipeline().addLast( FRAME_PREPENDER, framePrepender );
|
|
|
|
|
|
|
|
ch.pipeline().addLast( BOSS_HANDLER, new HandlerBoss() );
|
|
|
|
--
|
2019-03-06 16:35:52 +01:00
|
|
|
2.21.0
|
2018-10-14 11:47:38 +02:00
|
|
|
|