Skip to content

Commit

Permalink
Ignore empty packets
Browse files Browse the repository at this point in the history
Make ignoring empty packets the default behavior vs hiding it
behind a configuration option, allowing such packets is less harmful
than the current handling of them
  • Loading branch information
electronicboy committed Sep 24, 2019
1 parent 420f783 commit 2b3b0ec
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 209 deletions.
111 changes: 0 additions & 111 deletions BungeeCord-Patches/0045-Add-Configuration-to-allow-empty-packets.patch

This file was deleted.

42 changes: 42 additions & 0 deletions BungeeCord-Patches/0045-Ignore-empty-packets.patch
@@ -0,0 +1,42 @@
From dc105ad9e7123923267007948e8323c5623ed7df Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Fri, 12 Oct 2018 14:28:52 +0100
Subject: [PATCH] Ignore empty packets

This patch puts the proxy more inline with the client in that empty
packets will be ignored. While empty packets are a sign of bad plugins,
they are effectivly harmless vs the cost of the exception in general

diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
index 9e9ea49c..71ddf022 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
@@ -36,6 +36,12 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
Object packetTypeInfo = null;
try
{
+ // Waterfall start
+ if (in.readableBytes() == 0) {
+ return;
+ }
+ // Waterfall end
+
int packetId = DefinedPacket.readVarInt( in );
packetTypeInfo = packetId;

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 e903fd09..25ee2027 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
@@ -30,7 +30,7 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
if ( buf[i] >= 0 )
{
int length = DefinedPacket.readVarInt( Unpooled.wrappedBuffer( buf ) );
- if ( length == 0 )
+ if ( false && length == 0) // Waterfall - ignore
{
throw new CorruptedFrameException( "Empty Packet!" );
}
--
2.23.0

@@ -1,14 +1,14 @@
From 5c4d4e11b2329b221394f7b216c749edc00c57bf Mon Sep 17 00:00:00 2001
From c47d272e783d604efcca9ebd9dadc69f2eccf750 Mon Sep 17 00:00:00 2001
From: creeper123123321 <creeper123123321@gmail.com>
Date: Thu, 17 Jan 2019 03:25:59 +0000
Subject: [PATCH] Don't use a bytebuf for packet decoding


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 98a54601..8de4d9be 100644
index 25ee2027..743d65e4 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
@@ -24,8 +24,7 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
@@ -17,8 +17,7 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
{
in.markReaderIndex();

Expand All @@ -18,7 +18,7 @@ index 98a54601..8de4d9be 100644
{
if ( !in.isReadable() )
{
@@ -33,10 +32,13 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
@@ -26,10 +25,13 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
return;
}

Expand All @@ -32,10 +32,10 @@ index 98a54601..8de4d9be 100644
+ in.resetReaderIndex();
+ int length = DefinedPacket.readVarInt( in );
+ // Waterfall end
if ( length == 0 && !allowEmptyPackets) // Waterfall
if ( false && length == 0) // Waterfall - ignore
{
throw new CorruptedFrameException( "Empty Packet!" );
@@ -46,26 +48,11 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
@@ -39,26 +41,11 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
{
in.resetReaderIndex();
return;
Expand Down Expand Up @@ -67,5 +67,5 @@ index 98a54601..8de4d9be 100644
}
}
--
2.21.0
2.23.0

@@ -1,4 +1,4 @@
From 66bf7487b7d6ac842ccb685b8e24d00cc63f6367 Mon Sep 17 00:00:00 2001
From 24451de40fd98201fd6cd75b113d0e10d8bfa0d6 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Mon, 14 Jan 2019 03:35:21 +0000
Subject: [PATCH] Provide an option to disable entity metadata rewriting
Expand All @@ -12,43 +12,43 @@ may also create various issues with mods which do not support this,
hence why the configuration option is provided

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 46adc983..0e69db36 100644
index 058cca67..6bc54495 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
@@ -214,4 +214,9 @@ public interface ProxyConfig
* @return should we allow empty packets
@@ -207,4 +207,9 @@ public interface ProxyConfig
* @return should we disable the tab completion limit for 1.13+ clients
*/
boolean isAllowEmptyPackets();
boolean isDisableModernTabLimiter();
+
+ /**
+ * @return Should we disable entity metadata rewriting?
+ */
+ boolean isDisableEntityMetadataRewrite();
}
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 f28f0111..41a71f65 100644
index 4ff8da6d..e860214f 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
@@ -53,6 +53,8 @@ public class WaterfallConfiguration extends Configuration {
*/
private boolean allowEmptyPackets = false;
@@ -42,6 +42,8 @@ public class WaterfallConfiguration extends Configuration {
private int tabThrottle = 1000;
private boolean disableModernTabLimiter = true;

+ private boolean disableEntityMetadataRewrite = false;
+
@Override
public void load() {
super.load();
@@ -65,6 +67,7 @@ public class WaterfallConfiguration extends Configuration {
@@ -53,6 +55,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);
+ disableEntityMetadataRewrite = config.getBoolean("disable_entity_metadata_rewrite", disableEntityMetadataRewrite);
}

@Override
@@ -96,4 +99,9 @@ public class WaterfallConfiguration extends Configuration {
public boolean isAllowEmptyPackets() {
return allowEmptyPackets;
@@ -79,4 +82,9 @@ public class WaterfallConfiguration extends Configuration {
public boolean isDisableModernTabLimiter() {
return disableModernTabLimiter;
}
+
+ @Override
Expand Down Expand Up @@ -233,5 +233,5 @@ index 00000000..cb81d1dd
+// Waterfall end
\ No newline at end of file
--
2.21.0 (Apple Git-120)
2.23.0

@@ -1,4 +1,4 @@
From 64d9097f51560007e15d0c3ef63a024e7562e4b1 Mon Sep 17 00:00:00 2001
From 94ced6ab8ca487304c30dfbed044e9510c436590 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Thu, 14 Mar 2019 07:44:06 +0000
Subject: [PATCH] Add ProxyDefineCommandsEvent
Expand Down Expand Up @@ -105,5 +105,5 @@ index fba84905..1f8a2439 100644
LiteralCommandNode dummy = LiteralArgumentBuilder.literal( command.getKey() )
.then( RequiredArgumentBuilder.argument( "args", StringArgumentType.greedyString() )
--
2.21.0
2.23.0

63 changes: 0 additions & 63 deletions BungeeCord-Patches/0048-Handle-empty-minecraft-packets.patch

This file was deleted.

@@ -1,4 +1,4 @@
From 9de373cbf48bf9e971def774c5611cf8dc91f891 Mon Sep 17 00:00:00 2001
From 1cd07eb6820d14d1a1970d7c8c056d6ee1d39767 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Wed, 20 Mar 2019 21:39:12 -0700
Subject: [PATCH] Use proper max length for serverbound chat packet
Expand Down Expand Up @@ -72,5 +72,5 @@ index ffcd815c..0ded6739 100644
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
{
--
2.21.0
2.23.0

@@ -1,4 +1,4 @@
From 2f6ad505879900bc8504ae63336e67f17b8cac8a Mon Sep 17 00:00:00 2001
From 38b999c122f1614d6dd763ef20f9feda9bcfddc0 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Tue, 26 Mar 2019 04:28:18 +0000
Subject: [PATCH] Report slow events in milliseconds
Expand Down Expand Up @@ -27,5 +27,5 @@ index 81bd18f0..9408e6c2 100644
}
return event;
--
2.21.0
2.23.0

@@ -1,11 +1,11 @@
From f8145502b28ce0b36f31ea74efe4ab1c743d8275 Mon Sep 17 00:00:00 2001
From 90298e0454419d72aa080e3c68cb268eac64a6b4 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 30 Mar 2019 15:11:11 +0000
Subject: [PATCH] Fix upstream javadocs


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 0e69db36..cbcf8a24 100644
index 6bc54495..fd422f36 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
@@ -16,22 +16,27 @@ public interface ProxyConfig
Expand Down Expand Up @@ -147,5 +147,5 @@ index 5d2b088c..be32ba89 100644
* @return the underlying executor service or compatible wrapper
*/
--
2.21.0
2.23.0

0 comments on commit 2b3b0ec

Please sign in to comment.