Make config limits configurable via system properties

This commit is contained in:
Nassim Jahnke committed 2026-05-08 18:24:17 +02:00
1 parent c95c839bb0
commit 9a8a01b753
2 files changed
+6 -2

No files matched your search

@@ -34,6 +34,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class ConfigurationState implements StorableObject {
private static final int MAX_SERVERBOUND_QUEUED_PACKETS = Integer.getInteger("viaversion.maxQueuedServerboundConfigPackets", 1000);
private static final int MAX_SERVERBOUND_QUEUED_BYTES = Integer.getInteger("viaversion.maxQueuedServerboundConfigPacketBytes", 1048576);
private static final QueuedPacket[] EMPTY_PACKET_ARRAY = new QueuedPacket[0];
private final List<QueuedPacket> packetQueue = new ArrayList<>();
private BridgePhase bridgePhase = BridgePhase.NONE;
@@ -42,6 +44,7 @@ public class ConfigurationState implements StorableObject {
private CompoundTag lastDimensionRegistry;
private ClientInformation clientInformation;
private int queuedServerboundBytes;
private int queuedServerboundPackets;
public BridgePhase bridgePhase() {
return bridgePhase;
@@ -78,10 +81,11 @@ public class ConfigurationState implements StorableObject {
public void addServerboundPacketToQueue(final PacketWrapper wrapper) {
final QueuedPacket queued = toQueuedPacket(wrapper, false, false);
final int bytes = queued.buf().readableBytes();
if (packetQueue.size() > 5000 || queuedServerboundBytes + bytes > 2097152) {
if (queuedServerboundPackets >= MAX_SERVERBOUND_QUEUED_PACKETS || queuedServerboundBytes + bytes > MAX_SERVERBOUND_QUEUED_BYTES) {
wrapper.user().disconnect("Sent too many packets during config phase");
return;
}
queuedServerboundPackets++;
queuedServerboundBytes += bytes;
packetQueue.add(queued);
}
+1 -1
View File
@@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=5.9.1
projectVersion=5.9.2-SNAPSHOT
# Smile emoji (note that modrinth may not have added the version on release yet)
mcVersions=26.1.2, 26.1.1, 26.1, 1.21.11, 1.21.10, 1.21.9, 1.21.8, 1.21.7, 1.21.6, 1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 1.20.6, 1.20.5, 1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9