Search in sources :

Example 1 with EncryptionPacket

use of net.runelite.protocol.api.update.EncryptionPacket in project runelite by runelite.

the class HandshakeResponseHandler method channelRead0.

@Override
protected void channelRead0(ChannelHandlerContext ctx, HandshakeResponsePacket handshakeResponse) throws Exception {
    Channel channel = ctx.channel();
    ChannelPipeline p = ctx.pipeline();
    CompletableFuture<HandshakeResponseType> handshakeFuture = client.getHandshakeFuture();
    assert handshakeFuture != null;
    if (handshakeResponse.getResponse() != HandshakeResponseType.RESPONSE_OK) {
        logger.warn("Non-ok response from server {}", handshakeResponse.getResponse());
        ctx.close();
        return;
    }
    // Send encryption packet
    EncryptionPacket encryptionPacket = new EncryptionPacket();
    encryptionPacket.setKey((byte) 0);
    channel.writeAndFlush(encryptionPacket);
    client.setState(ClientState.CONNECTED);
    logger.info("Client is now connected!");
    p.replace("decoder", "decoder", new ArchiveResponseDecoder());
    handshakeFuture.complete(handshakeResponse.getResponse());
}
Also used : HandshakeResponseType(net.runelite.protocol.api.login.HandshakeResponseType) EncryptionPacket(net.runelite.protocol.api.update.EncryptionPacket) Channel(io.netty.channel.Channel) ChannelPipeline(io.netty.channel.ChannelPipeline) ArchiveResponseDecoder(net.runelite.protocol.update.decoders.ArchiveResponseDecoder)

Example 2 with EncryptionPacket

use of net.runelite.protocol.api.update.EncryptionPacket in project runelite by runelite.

the class EncryptionDecoder method decode.

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    if (in.getByte(in.readerIndex()) != UpdateOpcodes.ENCRYPTION) {
        ctx.fireChannelRead(in.retain());
        return;
    }
    in.readByte();
    byte xorKey = in.readByte();
    // always 0
    in.readShort();
    EncryptionPacket encryptionPacket = new EncryptionPacket();
    encryptionPacket.setKey(xorKey);
    out.add(encryptionPacket);
}
Also used : EncryptionPacket(net.runelite.protocol.api.update.EncryptionPacket)

Aggregations

EncryptionPacket (net.runelite.protocol.api.update.EncryptionPacket)2 Channel (io.netty.channel.Channel)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 HandshakeResponseType (net.runelite.protocol.api.login.HandshakeResponseType)1 ArchiveResponseDecoder (net.runelite.protocol.update.decoders.ArchiveResponseDecoder)1