Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Limit maximum amount of known packs by vanilla defaults (#1303)
Dieser Commit ist enthalten in:
Ursprung
b50f9eceff
Commit
7e45c17b04
@ -21,16 +21,25 @@ import com.velocitypowered.api.network.ProtocolVersion;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
|
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class KnownPacksPacket implements MinecraftPacket {
|
public class KnownPacksPacket implements MinecraftPacket {
|
||||||
|
|
||||||
|
private static final int MAX_LENGTH_PACKS = Integer.getInteger("velocity.max-known-packs", 64);
|
||||||
|
private static final QuietDecoderException TOO_MANY_PACKS =
|
||||||
|
new QuietDecoderException("too many known packs");
|
||||||
|
|
||||||
private KnownPack[] packs;
|
private KnownPack[] packs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
public void decode(ByteBuf buf, ProtocolUtils.Direction direction,
|
||||||
ProtocolVersion protocolVersion) {
|
ProtocolVersion protocolVersion) {
|
||||||
final int packCount = ProtocolUtils.readVarInt(buf);
|
final int packCount = ProtocolUtils.readVarInt(buf);
|
||||||
|
if (packCount > MAX_LENGTH_PACKS) {
|
||||||
|
throw TOO_MANY_PACKS;
|
||||||
|
}
|
||||||
|
|
||||||
final KnownPack[] packs = new KnownPack[packCount];
|
final KnownPack[] packs = new KnownPack[packCount];
|
||||||
|
|
||||||
for (int i = 0; i < packCount; i++) {
|
for (int i = 0; i < packCount; i++) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren