mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-01-26 22:21:29 +01:00
try to fix spam part 2
This commit is contained in:
parent
22d07a7ea7
commit
d376b4ae4f
@ -42,7 +42,7 @@ class CompressionCodec(val threshold: Int) : MessageToMessageCodec<ByteBuf, Byte
|
|||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun decode(ctx: ChannelHandlerContext, input: ByteBuf, out: MutableList<Any>) {
|
override fun decode(ctx: ChannelHandlerContext, input: ByteBuf, out: MutableList<Any>) {
|
||||||
if (input.isReadable) {
|
if (!input.isReadable || !ctx.channel().isActive) return
|
||||||
val outLength = Type.VAR_INT.readPrimitive(input)
|
val outLength = Type.VAR_INT.readPrimitive(input)
|
||||||
if (outLength == 0) {
|
if (outLength == 0) {
|
||||||
out.add(input.retain())
|
out.add(input.retain())
|
||||||
@ -70,6 +70,5 @@ class CompressionCodec(val threshold: Int) : MessageToMessageCodec<ByteBuf, Byte
|
|||||||
output.release()
|
output.release()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import javax.crypto.Cipher
|
|||||||
|
|
||||||
class CryptoCodec(val cipherDecode: Cipher, var cipherEncode: Cipher) : MessageToMessageCodec<ByteBuf, ByteBuf>() {
|
class CryptoCodec(val cipherDecode: Cipher, var cipherEncode: Cipher) : MessageToMessageCodec<ByteBuf, ByteBuf>() {
|
||||||
override fun decode(ctx: ChannelHandlerContext, msg: ByteBuf, out: MutableList<Any>) {
|
override fun decode(ctx: ChannelHandlerContext, msg: ByteBuf, out: MutableList<Any>) {
|
||||||
|
if (!ctx.channel().isActive) return
|
||||||
val i = msg.readerIndex()
|
val i = msg.readerIndex()
|
||||||
val size = msg.readableBytes()
|
val size = msg.readableBytes()
|
||||||
msg.writerIndex(i + cipherDecode.update(msg.nioBuffer(), msg.nioBuffer(i, cipherDecode.getOutputSize(size))))
|
msg.writerIndex(i + cipherDecode.update(msg.nioBuffer(), msg.nioBuffer(i, cipherDecode.getOutputSize(size))))
|
||||||
|
@ -9,6 +9,7 @@ import us.myles.ViaVersion.exception.CancelEncoderException
|
|||||||
|
|
||||||
class ViaCodec(val info: UserConnection) : MessageToMessageCodec<ByteBuf, ByteBuf>() {
|
class ViaCodec(val info: UserConnection) : MessageToMessageCodec<ByteBuf, ByteBuf>() {
|
||||||
override fun decode(ctx: ChannelHandlerContext, bytebuf: ByteBuf, out: MutableList<Any>) {
|
override fun decode(ctx: ChannelHandlerContext, bytebuf: ByteBuf, out: MutableList<Any>) {
|
||||||
|
if (!ctx.channel().isActive) return
|
||||||
if (!info.checkIncomingPacket()) throw CancelDecoderException.generate(null)
|
if (!info.checkIncomingPacket()) throw CancelDecoderException.generate(null)
|
||||||
if (!info.shouldTransformPacket()) {
|
if (!info.shouldTransformPacket()) {
|
||||||
out.add(bytebuf.retain())
|
out.add(bytebuf.retain())
|
||||||
|
Loading…
Reference in New Issue
Block a user