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());
}
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);
}
Aggregations