mirror of
https://github.com/PaperMC/Waterfall.git
synced 2025-01-01 05:27:47 +01:00
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.
This commit is contained in:
parent
f48db6b757
commit
22ce5f5012
@ -0,0 +1,106 @@
|
||||
From d46df55add6b43e643888128c3776da8f78d63f1 Mon Sep 17 00:00:00 2001
|
||||
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
|
||||
index 8680fd9b..f792426e 100644
|
||||
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
||||
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
||||
@@ -191,4 +191,6 @@ public interface ProxyConfig
|
||||
* @return should we disable the tab completion limit for 1.13+ clients
|
||||
*/
|
||||
boolean isDisableModernTabLimiter();
|
||||
+
|
||||
+ 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
|
||||
index 29e54dba..880a3dc7 100644
|
||||
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
||||
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
||||
@@ -12,6 +12,13 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
||||
{
|
||||
|
||||
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
|
||||
@@ -31,7 +38,7 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
||||
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
|
||||
index d343e9b8..ea06f3ba 100644
|
||||
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
||||
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
||||
@@ -49,6 +49,17 @@ public class WaterfallConfiguration extends Configuration {
|
||||
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();
|
||||
@@ -61,6 +72,7 @@ public class WaterfallConfiguration extends Configuration {
|
||||
// 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
|
||||
@@ -92,4 +104,9 @@ public class WaterfallConfiguration extends Configuration {
|
||||
public boolean isDisableModernTabLimiter() {
|
||||
return disableModernTabLimiter;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isAllowEmptyPackets() {
|
||||
+ return false;
|
||||
+ }
|
||||
}
|
||||
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
|
||||
index c26fc55b..3f082afb 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
||||
@@ -139,7 +139,7 @@ public class PipelineUtils
|
||||
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() );
|
||||
--
|
||||
2.19.1
|
||||
|
Loading…
Reference in New Issue
Block a user