Cancel Bungee packet encoding when closed (#2448)

This commit is contained in:
Juan Cruz Linsalata 2021-04-24 13:30:08 -03:00 committed by GitHub
parent ad0842c107
commit f18e2b3875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,10 @@ public class BungeeChannelInitializer extends ChannelInitializer<Channel> {
@Override
protected void initChannel(Channel socketChannel) throws Exception {
if (!socketChannel.isActive()) {
return;
}
UserConnection info = new UserConnection(socketChannel);
// init protocol
new ProtocolPipeline(info);

View File

@ -37,6 +37,10 @@ public class BungeeDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
@Override
protected void decode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
if (!ctx.channel().isActive()) {
throw CancelDecoderException.generate(null);
}
if (!info.checkIncomingPacket()) throw CancelDecoderException.generate(null);
if (!info.shouldTransformPacket()) {
out.add(bytebuf.retain());

View File

@ -39,6 +39,10 @@ public class BungeeEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
@Override
protected void encode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> out) throws Exception {
if (!ctx.channel().isActive()) {
throw CancelEncoderException.generate(null);
}
if (!info.checkOutgoingPacket()) throw CancelEncoderException.generate(null);
if (!info.shouldTransformPacket()) {
out.add(bytebuf.retain());