Add some means to quickly overlook deframing issues
This commit is contained in:
@@ -30,12 +30,15 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
import io.netty.handler.codec.CorruptedFrameException;
|
import io.netty.handler.codec.CorruptedFrameException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frames Minecraft server packets which are prefixed by a 21-bit VarInt encoding.
|
* Frames Minecraft server packets which are prefixed by a 21-bit VarInt encoding.
|
||||||
*/
|
*/
|
||||||
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(MinecraftVarintFrameDecoder.class);
|
||||||
private static final QuietRuntimeException FRAME_DECODER_FAILED =
|
private static final QuietRuntimeException FRAME_DECODER_FAILED =
|
||||||
new QuietRuntimeException("A packet frame decoder failed. For more information, launch "
|
new QuietRuntimeException("A packet frame decoder failed. For more information, launch "
|
||||||
+ "Velocity with -Dvelocity.packet-decode-logging=true to see more.");
|
+ "Velocity with -Dvelocity.packet-decode-logging=true to see more.");
|
||||||
@@ -131,6 +134,15 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||||
|
if (MinecraftDecoder.DEBUG) {
|
||||||
|
LOGGER.atWarn()
|
||||||
|
.withThrowable(cause)
|
||||||
|
.log("Exception caught while decoding frame for {}", ctx.channel().remoteAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a VarInt from the buffer of up to 21 bits in size.
|
* Reads a VarInt from the buffer of up to 21 bits in size.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user