Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.murion.engine.network.game.protocol.connection.decoder.login;
- import com.murion.engine.network.game.protocol.connection.event.login.LobbyPullEvent;
- import com.murion.engine.network.utilities.Base37Utils;
- import com.murion.engine.network.utilities.ByteBufUtils;
- import com.murion.engine.network.utilities.LoginUtils;
- import com.murion.util.security.IsaacGroup;
- import io.netty.buffer.ByteBuf;
- import io.netty.channel.ChannelHandlerContext;
- import io.netty.handler.codec.ByteToMessageDecoder;
- import java.util.List;
- /**
- * @author _Jordan <jordan.abraham1997@gmail.com>
- */
- public class LobbyDecoder extends ByteToMessageDecoder {
- @Override
- protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
- if (!in.isReadable()) {
- ctx.pipeline().remove(this);
- return;
- }
- ByteBuf block = LoginUtils.getRSABlock(in);
- int blockId = block.readUnsignedByte();
- if (blockId != 10) {
- ctx.channel().disconnect().sync();
- return;
- }
- int[] isaacSeed = LoginUtils.setIsaacSeeds(block, new int[4]);
- block.readLong();
- String password = ByteBufUtils.readString(block);
- block.readLong();
- block.readLong();
- block = LoginUtils.getXTEABlock(in, isaacSeed);
- String username = block.readByte() == 1 ? ByteBufUtils.readString(block) : Base37Utils.decodeBase37(block.readLong());
- block.readUnsignedByte();
- block.readUnsignedByte();
- block.skipBytes(24);
- ByteBufUtils.readString(block);
- IsaacGroup group = LoginUtils.getIsaacGroup(isaacSeed);
- out.add(new LobbyPullEvent(username, password, group));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement