Advertisement
Guest User

Untitled

a guest
Mar 16th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.74 KB | None | 0 0
  1. package com.murion.engine.network.game.protocol.connection.decoder.login;
  2.  
  3. import com.murion.engine.network.game.protocol.connection.event.login.LobbyPullEvent;
  4. import com.murion.engine.network.utilities.Base37Utils;
  5. import com.murion.engine.network.utilities.ByteBufUtils;
  6. import com.murion.engine.network.utilities.LoginUtils;
  7. import com.murion.util.security.IsaacGroup;
  8. import io.netty.buffer.ByteBuf;
  9. import io.netty.channel.ChannelHandlerContext;
  10. import io.netty.handler.codec.ByteToMessageDecoder;
  11.  
  12. import java.util.List;
  13.  
  14. /**
  15.  * @author _Jordan <jordan.abraham1997@gmail.com>
  16.  */
  17. public class LobbyDecoder extends ByteToMessageDecoder {
  18.  
  19.     @Override
  20.     protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
  21.         if (!in.isReadable()) {
  22.             ctx.pipeline().remove(this);
  23.             return;
  24.         }
  25.  
  26.         ByteBuf block = LoginUtils.getRSABlock(in);
  27.         int blockId = block.readUnsignedByte();
  28.         if (blockId != 10) {
  29.             ctx.channel().disconnect().sync();
  30.             return;
  31.         }
  32.         int[] isaacSeed = LoginUtils.setIsaacSeeds(block, new int[4]);
  33.         block.readLong();
  34.         String password = ByteBufUtils.readString(block);
  35.         block.readLong();
  36.         block.readLong();
  37.         block = LoginUtils.getXTEABlock(in, isaacSeed);
  38.         String username = block.readByte() == 1 ? ByteBufUtils.readString(block) : Base37Utils.decodeBase37(block.readLong());
  39.         block.readUnsignedByte();
  40.         block.readUnsignedByte();
  41.         block.skipBytes(24);
  42.         ByteBufUtils.readString(block);
  43.         IsaacGroup group = LoginUtils.getIsaacGroup(isaacSeed);
  44.         out.add(new LobbyPullEvent(username, password, group));
  45.     }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement