Skip to content

Commit

Permalink
Make protocol limit for plugin messages sent by client configurable
Browse files Browse the repository at this point in the history
helps out with SpigotMC#3509
  • Loading branch information
Outfluencer authored Dec 8, 2023
1 parent 231024b commit 92e1f63
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
public class PluginMessage extends DefinedPacket
{

public static int MAX_CLIENT_PAYLOAD_SIZE = Integer.getInteger( "net.md_5.bungee.max_client_payload_size", Short.MAX_VALUE );

public static final Function<String, String> MODERNISE = new Function<String, String>()
{
@Override
Expand Down Expand Up @@ -60,7 +62,7 @@ public String apply(String tag)
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf, 20 );
int maxSize = ( direction == ProtocolConstants.Direction.TO_SERVER ) ? Short.MAX_VALUE : 0x100000;
int maxSize = ( direction == ProtocolConstants.Direction.TO_SERVER ) ? MAX_CLIENT_PAYLOAD_SIZE : 0x100000;
Preconditions.checkArgument( buf.readableBytes() <= maxSize, "Payload too large" );
data = new byte[ buf.readableBytes() ];
buf.readBytes( data );
Expand Down

0 comments on commit 92e1f63

Please sign in to comment.