Skip to content

Commit

Permalink
reduce max frame lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
hex-agon committed Jul 29, 2023
1 parent 2f0b594 commit 510b60f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class HelloHandler(

val pipeline = ctx.pipeline()
pipeline.remove(this)
pipeline.replace("encoder", "encoder", ProtocolEncoder(cryptKey))
pipeline.addLast("framer", LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 10000, 1, 2, 1, 0, true))
pipeline.replace("encoder", "protocolEncoder", ProtocolEncoder(cryptKey))
pipeline.addLast("framer", LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 2500, 1, 2, 1, 0, true))
pipeline.addLast("handoverHandler", HandoverHandler(gameServer, cryptKey))
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package work.fking.pangya.login.net.pipe

import io.netty.channel.ChannelHandler
import io.netty.channel.ChannelHandler.Sharable
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelInboundHandlerAdapter
import io.netty.handler.codec.LengthFieldBasedFrameDecoder
Expand All @@ -14,7 +14,7 @@ import java.nio.ByteOrder

private val LOGGER = LoggerFactory.getLogger(HelloHandler::class.java)

@ChannelHandler.Sharable
@Sharable
class HelloHandler(
private val loginServer: LoginServer
) : ChannelInboundHandlerAdapter() {
Expand All @@ -24,10 +24,11 @@ class HelloHandler(
val cryptKey = Rand.maxInclusive(PangCrypt.CRYPT_KEY_MAX)
LOGGER.debug("New connection from {}, selected cryptKey={}", channel.remoteAddress(), cryptKey)
ctx.writeAndFlush(HelloPacket(cryptKey))

val pipeline = channel.pipeline()
pipeline.remove(this)
pipeline.replace("encoder", "encoder", ProtocolEncoder(cryptKey))
pipeline.addLast("framer", LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 10000, 1, 2, 1, 0, true))
pipeline.replace("encoder", "protocolEncoder", ProtocolEncoder(cryptKey))
pipeline.addLast("framer", LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 250, 1, 2, 1, 0, true))
pipeline.addLast("loginHandler", LoginHandler(loginServer, cryptKey))
}
}

0 comments on commit 510b60f

Please sign in to comment.