Class MaplePacketEncoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToByteEncoder<Object>
server.netty.MaplePacketEncoder
- All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelOutboundHandler
Netty 出站處理器,負責將明文封包位元組陣列加密後寫入網路緩衝區。
繼承自 MessageToByteEncoder,對每個待發送的 byte[] 執行:
- 向
MapleAESOFB取得 4 位元組封包頭(含長度與版本資訊)。 - 以
MapleAESOFB.crypt(byte[])就地加密,並在客戶端鎖(client.getLock())保護下 組合「頭+密文」後寫入ByteBuf,確保多執行緒下的加密序列一致性。 - 若
ServerConstants.CUSTOM_ENCRYPTION開啟,以隨機位元組mtp對全包 XOR。
當尚未建立 MapleClient(握手封包)時跳過 AES 加密,僅進行選用的 XOR。
當 ServerConstants.LOG_Handle_PACKETS 啟用時,印出 SendPacketOpcode
名稱、包頭十六進位與封包長度,並寫入已知封包日誌。
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class io.netty.handler.codec.MessageToByteEncoder
acceptOutboundMessage, allocateBuffer, isPreferDirect, writeMethods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
Constructor Details
-
MaplePacketEncoder
public MaplePacketEncoder()
-
-
Method Details
-
encode
-