cache: split cache client and server into their own projects

Split handshake and update protocol also into their own projects
This commit is contained in:
Adam
2017-12-28 21:13:18 -05:00
parent c4bee1127c
commit 82d277a8a5
59 changed files with 1114 additions and 391 deletions

71
cache-client/pom.xml Normal file
View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.runelite</groupId>
<artifactId>runelite-parent</artifactId>
<version>1.2.11-SNAPSHOT</version>
</parent>
<groupId>net.runelite</groupId>
<artifactId>cache-client</artifactId>
<name>Cache Client</name>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>protocol</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -26,7 +26,7 @@ package net.runelite.cache.client;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import net.runelite.cache.protocol.packets.ArchiveResponsePacket;
import net.runelite.protocol.api.update.ArchiveResponsePacket;
public class ArchiveResponseHandler extends SimpleChannelInboundHandler<ArchiveResponsePacket>
{

View File

@@ -49,15 +49,14 @@ import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import net.runelite.cache.index.ArchiveData;
import net.runelite.cache.index.IndexData;
import net.runelite.cache.protocol.decoders.HandshakeResponseDecoder;
import net.runelite.cache.protocol.encoders.ArchiveRequestEncoder;
import net.runelite.cache.protocol.encoders.EncryptionEncoder;
import net.runelite.cache.protocol.encoders.HandshakeEncoder;
import net.runelite.cache.protocol.packets.ArchiveRequestPacket;
import net.runelite.cache.protocol.packets.HandshakePacket;
import net.runelite.cache.protocol.packets.HandshakeResponseType;
import net.runelite.cache.protocol.packets.HandshakeType;
import net.runelite.protocol.update.decoders.HandshakeResponseDecoder;
import net.runelite.protocol.update.encoders.ArchiveRequestEncoder;
import net.runelite.protocol.update.encoders.EncryptionEncoder;
import net.runelite.protocol.api.update.ArchiveRequestPacket;
import net.runelite.protocol.api.login.HandshakeResponseType;
import net.runelite.cache.util.Crc32;
import net.runelite.protocol.api.handshake.UpdateHandshakePacket;
import net.runelite.protocol.handshake.UpdateHandshakeEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -124,7 +123,7 @@ public class CacheClient implements AutoCloseable
);
p.addLast(
new HandshakeEncoder(),
new UpdateHandshakeEncoder(),
new EncryptionEncoder(),
new ArchiveRequestEncoder()
);
@@ -138,8 +137,7 @@ public class CacheClient implements AutoCloseable
public CompletableFuture<HandshakeResponseType> handshake()
{
HandshakePacket handshakePacket = new HandshakePacket();
handshakePacket.setType(HandshakeType.ON_DEMAND);
UpdateHandshakePacket handshakePacket = new UpdateHandshakePacket();
handshakePacket.setRevision(getClientRevision());
state = ClientState.HANDSHAKING;

View File

@@ -29,10 +29,10 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.SimpleChannelInboundHandler;
import java.util.concurrent.CompletableFuture;
import net.runelite.cache.protocol.decoders.ArchiveResponseDecoder;
import net.runelite.cache.protocol.packets.EncryptionPacket;
import net.runelite.cache.protocol.packets.HandshakeResponsePacket;
import net.runelite.cache.protocol.packets.HandshakeResponseType;
import net.runelite.protocol.update.decoders.ArchiveResponseDecoder;
import net.runelite.protocol.api.update.EncryptionPacket;
import net.runelite.protocol.api.handshake.HandshakeResponsePacket;
import net.runelite.protocol.api.login.HandshakeResponseType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -28,7 +28,7 @@ import java.io.File;
import java.util.concurrent.CompletableFuture;
import net.runelite.cache.CacheProperties;
import net.runelite.cache.fs.Store;
import net.runelite.cache.protocol.packets.HandshakeResponseType;
import net.runelite.protocol.api.login.HandshakeResponseType;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;

87
cache-server/pom.xml Normal file
View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.runelite</groupId>
<artifactId>runelite-parent</artifactId>
<version>1.2.11-SNAPSHOT</version>
</parent>
<groupId>net.runelite</groupId>
<artifactId>cache-server</artifactId>
<name>Cache Server</name>
<properties>
<cache.version>160</cache.version>
</properties>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>protocol</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.runelite.rs</groupId>
<artifactId>cache</artifactId>
<version>${cache.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -26,7 +26,6 @@ package net.runelite.cache.server;
import com.google.common.primitives.Ints;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import java.io.IOException;
@@ -38,8 +37,8 @@ import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import net.runelite.cache.fs.jagex.CompressionType;
import net.runelite.cache.fs.jagex.DiskStorage;
import net.runelite.cache.protocol.packets.ArchiveRequestPacket;
import net.runelite.cache.protocol.packets.ArchiveResponsePacket;
import net.runelite.protocol.api.update.ArchiveRequestPacket;
import net.runelite.protocol.api.update.ArchiveResponsePacket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,7 +78,7 @@ public class ArchiveRequestHandler extends SimpleChannelInboundHandler<ArchiveRe
// index 255 data, for each index:
// 4 byte crc
// 4 byte revision
ByteBuf buffer = Unpooled.buffer(store.getIndexes().size() * 8);
ByteBuf buffer = ctx.alloc().heapBuffer(store.getIndexes().size() * 8);
for (Index i : store.getIndexes())
{
buffer.writeInt(i.getCrc());
@@ -87,6 +86,7 @@ public class ArchiveRequestHandler extends SimpleChannelInboundHandler<ArchiveRe
}
compressed = compress(CompressionType.NONE, Arrays.copyOf(buffer.array(), buffer.readableBytes()));
buffer.release();
}
else
{

View File

@@ -28,7 +28,11 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
import net.runelite.cache.protocol.packets.EncryptionPacket;
import static net.runelite.protocol.update.decoders.UpdateOpcodes.ARCHIVE_REQUEST_HIGH;
import static net.runelite.protocol.update.decoders.UpdateOpcodes.ARCHIVE_REQUEST_LOW;
import static net.runelite.protocol.update.decoders.UpdateOpcodes.CLIENT_LOGGED_IN;
import static net.runelite.protocol.update.decoders.UpdateOpcodes.CLIENT_LOGGED_OUT;
import static net.runelite.protocol.update.decoders.UpdateOpcodes.ENCRYPTION;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,13 +40,6 @@ public class CacheFrameDecoder extends ByteToMessageDecoder
{
private static final Logger logger = LoggerFactory.getLogger(CacheFrameDecoder.class);
public static final int ARCHIVE_REQUEST_LOW = 0;
public static final int ARCHIVE_REQUEST_HIGH = 1;
public static final int ENCRYPTION = EncryptionPacket.OPCODE;
public static final int HANDSHAKE_ON_DEMAND = 15;
private ClientState state = ClientState.HANDSHAKING;
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
{
@@ -54,26 +51,12 @@ public class CacheFrameDecoder extends ByteToMessageDecoder
switch (opcode)
{
case HANDSHAKE_ON_DEMAND:
length = 5;
if (state != ClientState.HANDSHAKING)
{
ctx.close();
return;
}
state = ClientState.CONNECTED;
break;
case ARCHIVE_REQUEST_LOW:
case ARCHIVE_REQUEST_HIGH:
case CLIENT_LOGGED_IN:
case CLIENT_LOGGED_OUT:
case ENCRYPTION:
length = 4;
if (state != ClientState.CONNECTED)
{
ctx.close();
return;
}
break;
default:
logger.debug("Unknown packet opcode from {}: {}",

View File

@@ -24,15 +24,15 @@
*/
package net.runelite.cache.server;
import net.runelite.cache.protocol.decoders.HandshakeDecoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import net.runelite.cache.protocol.decoders.ArchiveRequestDecoder;
import net.runelite.cache.protocol.decoders.EncryptionDecoder;
import net.runelite.cache.protocol.encoders.ArchiveResponseEncoder;
import net.runelite.cache.protocol.encoders.HandshakeResponseEncoder;
import net.runelite.cache.protocol.encoders.XorEncoder;
import net.runelite.protocol.update.decoders.ArchiveRequestDecoder;
import net.runelite.protocol.update.decoders.EncryptionDecoder;
import net.runelite.protocol.update.encoders.ArchiveResponseEncoder;
import net.runelite.protocol.update.encoders.XorEncoder;
import net.runelite.protocol.handshake.HandshakeDecoder;
import net.runelite.protocol.handshake.HandshakeResponseEncoder;
public class CacheServerInitializer extends ChannelInitializer<SocketChannel>
{
@@ -49,8 +49,8 @@ public class CacheServerInitializer extends ChannelInitializer<SocketChannel>
ChannelPipeline p = ch.pipeline();
p.addLast(
new CacheFrameDecoder(),
new HandshakeDecoder(),
new CacheFrameDecoder(),
new EncryptionDecoder(),
new ArchiveRequestDecoder()
);

View File

@@ -27,8 +27,8 @@ package net.runelite.cache.server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.SimpleChannelInboundHandler;
import net.runelite.cache.protocol.encoders.XorEncoder;
import net.runelite.cache.protocol.packets.EncryptionPacket;
import net.runelite.protocol.update.encoders.XorEncoder;
import net.runelite.protocol.api.update.EncryptionPacket;
public class EncryptionHandler extends SimpleChannelInboundHandler<EncryptionPacket>
{

View File

@@ -25,15 +25,16 @@
package net.runelite.cache.server;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.SimpleChannelInboundHandler;
import net.runelite.cache.protocol.packets.HandshakePacket;
import net.runelite.cache.protocol.packets.HandshakeResponsePacket;
import net.runelite.cache.protocol.packets.HandshakeResponseType;
import net.runelite.cache.protocol.packets.HandshakeType;
import net.runelite.protocol.api.handshake.HandshakeResponsePacket;
import net.runelite.protocol.api.login.HandshakeResponseType;
import net.runelite.protocol.api.handshake.UpdateHandshakePacket;
import net.runelite.protocol.handshake.HandshakeDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HandshakeHandler extends SimpleChannelInboundHandler<HandshakePacket>
public class HandshakeHandler extends SimpleChannelInboundHandler<UpdateHandshakePacket>
{
private static final Logger logger = LoggerFactory.getLogger(HandshakeHandler.class);
@@ -45,14 +46,9 @@ public class HandshakeHandler extends SimpleChannelInboundHandler<HandshakePacke
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, HandshakePacket handshakePacket) throws Exception
protected void channelRead0(ChannelHandlerContext ctx, UpdateHandshakePacket handshakePacket) throws Exception
{
if (handshakePacket.getType() != HandshakeType.ON_DEMAND)
{
logger.warn("Expected handshake type ON_DEMAND");
ctx.close();
return;
}
ChannelPipeline pipeline = ctx.pipeline();
if (handshakePacket.getRevision() != server.getRevision())
{
@@ -62,13 +58,16 @@ public class HandshakeHandler extends SimpleChannelInboundHandler<HandshakePacke
return;
}
logger.info("Handshake complete from client {}, type {}, revision {}",
ctx.channel().remoteAddress(), handshakePacket.getType(),
logger.info("Handshake complete from client {}, revision {}",
ctx.channel().remoteAddress(),
handshakePacket.getRevision());
HandshakeResponsePacket handshakeResponse = new HandshakeResponsePacket();
handshakeResponse.setResponse(HandshakeResponseType.RESPONSE_OK);
ctx.channel().writeAndFlush(handshakeResponse);
pipeline.remove(HandshakeDecoder.class);
pipeline.addFirst(new CacheFrameDecoder());
}
}

12
cache/pom.xml vendored
View File

@@ -156,6 +156,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.runelite.cache.definitions.InventoryDefinition;
import net.runelite.cache.definitions.loaders.InventoryLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
public class InventoryManager
{
private final Store store;
private final List<InventoryDefinition> inventories = new ArrayList<>();
public InventoryManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
InventoryLoader loader = new InventoryLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.INV.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles())
{
InventoryDefinition inv = loader.load(file.getFileId(), file.getContents());
inventories.add(inv);
}
}
public List<InventoryDefinition> getInventories()
{
return Collections.unmodifiableList(inventories);
}
public InventoryDefinition findInventory(int id)
{
for (InventoryDefinition def : inventories)
{
if (def.id == id)
{
return def;
}
}
return null;
}
}

View File

@@ -1,44 +0,0 @@
package net.runelite.cache.protocol.packets;
public class ArchiveRequestPacket
{
private boolean priority;
private int index;
private int archive;
@Override
public String toString()
{
return "ArchiveRequestPacket{" + "priority=" + priority + ", index=" + index + ", archive=" + archive + '}';
}
public boolean isPriority()
{
return priority;
}
public void setPriority(boolean priority)
{
this.priority = priority;
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public int getArchive()
{
return archive;
}
public void setArchive(int archive)
{
this.archive = archive;
}
}

View File

@@ -1,44 +0,0 @@
package net.runelite.cache.protocol.packets;
public class ArchiveResponsePacket
{
private int index;
private int archive;
private byte[] data;
@Override
public String toString()
{
return "ArchiveResponsePacket{" + "index=" + index + ", archive=" + archive + ", data=" + data + '}';
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public int getArchive()
{
return archive;
}
public void setArchive(int archive)
{
this.archive = archive;
}
public byte[] getData()
{
return data;
}
public void setData(byte[] data)
{
this.data = data;
}
}

View File

@@ -1,24 +0,0 @@
package net.runelite.cache.protocol.packets;
public class EncryptionPacket
{
public static final int OPCODE = 4;
private byte key;
@Override
public String toString()
{
return "EncryptionPacket{" + "key=" + key + '}';
}
public byte getKey()
{
return key;
}
public void setKey(byte key)
{
this.key = key;
}
}

View File

@@ -1,33 +0,0 @@
package net.runelite.cache.protocol.packets;
public class HandshakePacket
{
private HandshakeType type;
private int revision;
@Override
public String toString()
{
return "HandshakePacket{" + "type=" + type + ", revision=" + revision + '}';
}
public HandshakeType getType()
{
return type;
}
public void setType(HandshakeType type)
{
this.type = type;
}
public int getRevision()
{
return revision;
}
public void setRevision(int revision)
{
this.revision = revision;
}
}

View File

@@ -1,22 +0,0 @@
package net.runelite.cache.protocol.packets;
public class HandshakeResponsePacket
{
private HandshakeResponseType response;
@Override
public String toString()
{
return "HandshakeResponsePacket{" + "response=" + response + '}';
}
public HandshakeResponseType getResponse()
{
return response;
}
public void setResponse(HandshakeResponseType response)
{
this.response = response;
}
}

View File

@@ -1,59 +0,0 @@
package net.runelite.cache.protocol.packets;
public enum HandshakeResponseType
{
RESPONSE_OK(0),
ACCOUNT_DISABLED(4),
ACCOUNT_ONLINE(5),
RESPONSE_OUTDATED(6),
WORLD_FULL(7),
SERVER_OFFLINE(8),
LIMITED_EXCEEDED(9),
BAD_SESSION_ID(10),
ACCOUNT_HIJACK(11),
MEMBERS_WORLD(12),
COULD_NOT_COMPLETE_LOGIN(13),
SERVER_BEING_UPDATED(14),
TOO_MANY_ATTEMPTS(16),
MEMBERS_ONLY_AREA(17),
ACCOUNT_LOCKED(18),
CLOSED_BETA(19),
INVALID_LOGINSERVER(20),
MALFORMED_PACKET(22),
NO_REPLY_FROM_LOGINSERVER(23),
ERR_LOADING_PROFILE(24),
UNEXPECTED_LOGINSERVER_RESPONSE(25),
IP_BANNED(26),
SERVICE_UNAVAILABLE(27),
NO_DISPLAY_NAME(31),
BILLING_ERROR(32),
ACCOUNT_INACCESSABLE(37),
VOTE_TO_PLAY(38),
NOT_ELIGIBLE(55),
NEED_AUTHENTICATOR(56),
AUTHENTICATOR_CODE_WRONG(57);
private final byte value;
private HandshakeResponseType(int value)
{
this.value = (byte) value;
}
public byte getValue()
{
return value;
}
public static HandshakeResponseType of(byte value)
{
for (HandshakeResponseType type : values())
{
if (type.value == value)
{
return type;
}
}
return null;
}
}

View File

@@ -1,30 +0,0 @@
package net.runelite.cache.protocol.packets;
public enum HandshakeType
{
ON_DEMAND(15);
private final byte value;
private HandshakeType(int value)
{
this.value = (byte) value;
}
public byte getValue()
{
return value;
}
public static HandshakeType of(byte value)
{
for (HandshakeType type : values())
{
if (type.value == value)
{
return type;
}
}
return null;
}
}

View File

@@ -73,6 +73,11 @@
<artifactId>cache</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.sql2o</groupId>

View File

@@ -37,10 +37,10 @@ import net.runelite.cache.client.CacheClient;
import net.runelite.cache.client.IndexInfo;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.Store;
import net.runelite.cache.protocol.packets.HandshakeResponseType;
import net.runelite.http.api.RuneliteAPI;
import net.runelite.http.service.cache.beans.CacheEntry;
import net.runelite.http.service.cache.beans.IndexEntry;
import net.runelite.protocol.api.login.HandshakeResponseType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -104,6 +104,8 @@
<modules>
<module>cache</module>
<module>cache-client</module>
<module>cache-server</module>
<module>deobfuscator</module>
<module>model-viewer</module>
<module>runelite-api</module>
@@ -117,6 +119,8 @@
<module>http-api</module>
<module>http-service</module>
<module>runelite-proxy</module>
<module>protocol-api</module>
<module>protocol</module>
</modules>
<dependencyManagement>

68
protocol-api/pom.xml Normal file
View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.runelite</groupId>
<artifactId>runelite-parent</artifactId>
<version>1.2.11-SNAPSHOT</version>
</parent>
<groupId>net.runelite</groupId>
<artifactId>protocol-api</artifactId>
<name>Protocol API</name>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -22,10 +22,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.server;
package net.runelite.protocol.api.handshake;
public enum ClientState
public abstract class HandshakePacket
{
HANDSHAKING,
CONNECTED
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.api.handshake;
import lombok.Data;
import net.runelite.protocol.api.login.HandshakeResponseType;
@Data
public class HandshakeResponsePacket
{
private HandshakeResponseType response;
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.api.handshake;
public enum HandshakeType
{
LOGIN(14),
UPDATE(15);
private final byte value;
HandshakeType(int value)
{
this.value = (byte) value;
}
public byte getValue()
{
return value;
}
public static HandshakeType of(byte value)
{
for (HandshakeType type : values())
{
if (type.value == value)
{
return type;
}
}
return null;
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.api.handshake;
import lombok.Data;
@Data
public class LoginHandshakePacket extends HandshakePacket
{
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.api.handshake;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UpdateHandshakePacket extends HandshakePacket
{
private int revision;
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.api.login;
public enum HandshakeResponseType
{
RESPONSE_OK(0),
LOGGED_IN(2),
INVALID_USERNAME_OR_PASSWORD(3),
ACCOUNT_DISABLED(4),
ACCOUNT_ONLINE(5),
RESPONSE_OUTDATED(6),
WORLD_FULL(7),
SERVER_OFFLINE(8),
LIMITED_EXCEEDED(9),
BAD_SESSION_ID(10),
ACCOUNT_HIJACK(11),
MEMBERS_WORLD(12),
COULD_NOT_COMPLETE_LOGIN(13),
SERVER_BEING_UPDATED(14),
TOO_MANY_ATTEMPTS(16),
MEMBERS_ONLY_AREA(17),
ACCOUNT_LOCKED(18),
CLOSED_BETA(19),
INVALID_LOGINSERVER(20),
PROFILE_TRANSFER(21),
MALFORMED_PACKET(22),
NO_REPLY_FROM_LOGINSERVER(23),
ERR_LOADING_PROFILE(24),
UNEXPECTED_LOGINSERVER_RESPONSE(25),
IP_BANNED(26),
SERVICE_UNAVAILABLE(27),
NO_DISPLAY_NAME(31),
BILLING_ERROR(32),
ACCOUNT_INACCESSABLE(37),
VOTE_TO_PLAY(38),
NOT_ELIGIBLE(55),
NEED_AUTHENTICATOR(56),
AUTHENTICATOR_CODE_WRONG(57);
private final byte value;
HandshakeResponseType(int value)
{
this.value = (byte) value;
}
public byte getValue()
{
return value;
}
public static HandshakeResponseType of(byte value)
{
for (HandshakeResponseType type : values())
{
if (type.value == value)
{
return type;
}
}
return null;
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.api.update;
public class ArchiveRequestPacket
{
private boolean priority;
private int index;
private int archive;
@Override
public String toString()
{
return "ArchiveRequestPacket{" + "priority=" + priority + ", index=" + index + ", archive=" + archive + '}';
}
public boolean isPriority()
{
return priority;
}
public void setPriority(boolean priority)
{
this.priority = priority;
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public int getArchive()
{
return archive;
}
public void setArchive(int archive)
{
this.archive = archive;
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.api.update;
public class ArchiveResponsePacket
{
private int index;
private int archive;
private byte[] data;
@Override
public String toString()
{
return "ArchiveResponsePacket{" + "index=" + index + ", archive=" + archive + ", data=" + data + '}';
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public int getArchive()
{
return archive;
}
public void setArchive(int archive)
{
this.archive = archive;
}
public byte[] getData()
{
return data;
}
public void setData(byte[] data)
{
this.data = data;
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.api.update;
import lombok.Data;
@Data
public class EncryptionPacket
{
private byte key;
}

74
protocol/pom.xml Normal file
View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.runelite</groupId>
<artifactId>runelite-parent</artifactId>
<version>1.2.11-SNAPSHOT</version>
</parent>
<groupId>net.runelite</groupId>
<artifactId>protocol</artifactId>
<name>Protocol</name>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>protocol-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.handshake;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import net.runelite.protocol.api.handshake.HandshakeType;
import net.runelite.protocol.api.handshake.LoginHandshakePacket;
import net.runelite.protocol.api.handshake.UpdateHandshakePacket;
@Slf4j
public class HandshakeDecoder extends ByteToMessageDecoder
{
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception
{
buf.markReaderIndex();
byte handshakeOpcode = buf.readByte();
HandshakeType handshakeType = HandshakeType.of(handshakeOpcode);
if (handshakeType == null)
{
log.warn("Unknown handshake type {} from {}",
handshakeOpcode, ctx.channel().remoteAddress());
ctx.close();
return;
}
switch (handshakeType)
{
case LOGIN:
{
LoginHandshakePacket packet = new LoginHandshakePacket();
out.add(packet);
break;
}
case UPDATE:
{
if (buf.readableBytes() < 4)
{
buf.resetReaderIndex();
return;
}
int revision = buf.readInt();
UpdateHandshakePacket packet = new UpdateHandshakePacket(revision);
out.add(packet);
break;
}
}
}
}

View File

@@ -22,13 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.encoders;
package net.runelite.protocol.handshake;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import net.runelite.cache.protocol.packets.HandshakeResponsePacket;
import net.runelite.cache.protocol.packets.HandshakeResponseType;
import net.runelite.protocol.api.handshake.HandshakeResponsePacket;
import net.runelite.protocol.api.login.HandshakeResponseType;
public class HandshakeResponseEncoder extends MessageToByteEncoder<HandshakeResponsePacket>
{

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,21 +22,20 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.encoders;
package net.runelite.protocol.handshake;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import net.runelite.cache.protocol.packets.HandshakePacket;
import net.runelite.protocol.api.handshake.HandshakeType;
import net.runelite.protocol.api.handshake.LoginHandshakePacket;
public class HandshakeEncoder extends MessageToByteEncoder<HandshakePacket>
public class LoginHandshakeEncoder extends MessageToByteEncoder<LoginHandshakePacket>
{
@Override
protected void encode(ChannelHandlerContext ctx, HandshakePacket handshakePacket, ByteBuf out) throws Exception
protected void encode(ChannelHandlerContext ctx, LoginHandshakePacket packet, ByteBuf buf) throws Exception
{
out.writeByte(handshakePacket.getType().getValue());
out.writeInt(handshakePacket.getRevision());
buf.writeByte(HandshakeType.LOGIN.getValue());
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.handshake;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import net.runelite.protocol.api.handshake.HandshakeType;
import net.runelite.protocol.api.handshake.UpdateHandshakePacket;
public class UpdateHandshakeEncoder extends MessageToByteEncoder<UpdateHandshakePacket>
{
@Override
protected void encode(ChannelHandlerContext ctx, UpdateHandshakePacket packet, ByteBuf buf) throws Exception
{
buf.writeByte(HandshakeType.UPDATE.getValue());
buf.writeInt(packet.getRevision());
}
}

View File

@@ -22,14 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.decoders;
package net.runelite.protocol.update.decoders;
import net.runelite.cache.server.CacheFrameDecoder;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
import net.runelite.cache.protocol.packets.ArchiveRequestPacket;
import net.runelite.protocol.api.update.ArchiveRequestPacket;
public class ArchiveRequestDecoder extends ByteToMessageDecoder
{
@@ -38,8 +37,8 @@ public class ArchiveRequestDecoder extends ByteToMessageDecoder
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
{
byte opcode = in.getByte(in.readerIndex());
if (opcode != CacheFrameDecoder.ARCHIVE_REQUEST_HIGH
&& opcode != CacheFrameDecoder.ARCHIVE_REQUEST_LOW)
if (opcode != UpdateOpcodes.ARCHIVE_REQUEST_HIGH
&& opcode != UpdateOpcodes.ARCHIVE_REQUEST_LOW)
{
ctx.fireChannelRead(in.retain());
return;

View File

@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.decoders;
package net.runelite.protocol.update.decoders;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -30,7 +30,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
import net.runelite.cache.fs.jagex.CompressionType;
import net.runelite.cache.protocol.packets.ArchiveResponsePacket;
import net.runelite.protocol.api.update.ArchiveResponsePacket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -22,14 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.decoders;
package net.runelite.protocol.update.decoders;
import net.runelite.cache.server.CacheFrameDecoder;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
import net.runelite.cache.protocol.packets.EncryptionPacket;
import net.runelite.protocol.api.update.EncryptionPacket;
public class EncryptionDecoder extends ByteToMessageDecoder
{
@@ -37,7 +36,7 @@ public class EncryptionDecoder extends ByteToMessageDecoder
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
{
if (in.getByte(in.readerIndex()) != CacheFrameDecoder.ENCRYPTION)
if (in.getByte(in.readerIndex()) != UpdateOpcodes.ENCRYPTION)
{
ctx.fireChannelRead(in.retain());
return;

View File

@@ -22,14 +22,14 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.decoders;
package net.runelite.protocol.update.decoders;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
import net.runelite.cache.protocol.packets.HandshakeResponsePacket;
import net.runelite.cache.protocol.packets.HandshakeResponseType;
import net.runelite.protocol.api.handshake.HandshakeResponsePacket;
import net.runelite.protocol.api.login.HandshakeResponseType;
public class HandshakeResponseDecoder extends ByteToMessageDecoder
{
@@ -37,11 +37,6 @@ public class HandshakeResponseDecoder extends ByteToMessageDecoder
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
{
if (in.readableBytes() < 1)
{
return;
}
byte response = in.readByte();
HandshakeResponsePacket handshakeResponse = new HandshakeResponsePacket();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,35 +22,25 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.decoders;
package net.runelite.protocol.update.decoders;
import net.runelite.cache.server.CacheFrameDecoder;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
import net.runelite.cache.protocol.packets.HandshakePacket;
import net.runelite.cache.protocol.packets.HandshakeType;
public class HandshakeDecoder extends ByteToMessageDecoder
public class LoggedInDecoder extends ByteToMessageDecoder
{
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> list) throws Exception
{
if (in.getByte(in.readerIndex()) != CacheFrameDecoder.HANDSHAKE_ON_DEMAND)
if (in.getByte(in.readerIndex()) != UpdateOpcodes.CLIENT_LOGGED_IN)
{
ctx.fireChannelRead(in.retain());
return;
}
byte type = in.readByte();
int revision = in.readInt();
HandshakePacket handshakePacket = new HandshakePacket();
handshakePacket.setType(HandshakeType.of(type));
handshakePacket.setRevision(revision);
out.add(handshakePacket);
in.skipBytes(4);
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.update.decoders;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
public class LoggedOutDecoder extends ByteToMessageDecoder
{
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> list) throws Exception
{
if (in.getByte(in.readerIndex()) != UpdateOpcodes.CLIENT_LOGGED_OUT)
{
ctx.fireChannelRead(in.retain());
return;
}
in.skipBytes(4);
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.protocol.update.decoders;
public class UpdateOpcodes
{
public static final int ARCHIVE_REQUEST_LOW = 0;
public static final int ARCHIVE_REQUEST_HIGH = 1;
public static final int CLIENT_LOGGED_IN = 2;
public static final int CLIENT_LOGGED_OUT = 3;
public static final int ENCRYPTION = 4;
}

View File

@@ -22,16 +22,15 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.encoders;
package net.runelite.protocol.update.encoders;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import net.runelite.cache.protocol.packets.ArchiveRequestPacket;
import net.runelite.protocol.api.update.ArchiveRequestPacket;
public class ArchiveRequestEncoder extends MessageToByteEncoder<ArchiveRequestPacket>
{
@Override
protected void encode(ChannelHandlerContext ctx, ArchiveRequestPacket archiveRequest, ByteBuf out) throws Exception
{

View File

@@ -22,13 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.encoders;
package net.runelite.protocol.update.encoders;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import net.runelite.cache.protocol.packets.ArchiveResponsePacket;
import net.runelite.protocol.api.update.ArchiveResponsePacket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -22,12 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.encoders;
package net.runelite.protocol.update.encoders;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import net.runelite.cache.protocol.packets.EncryptionPacket;
import net.runelite.protocol.api.update.EncryptionPacket;
import net.runelite.protocol.update.decoders.UpdateOpcodes;
public class EncryptionEncoder extends MessageToByteEncoder<EncryptionPacket>
{
@@ -35,7 +36,7 @@ public class EncryptionEncoder extends MessageToByteEncoder<EncryptionPacket>
@Override
protected void encode(ChannelHandlerContext ctx, EncryptionPacket encryptionPacket, ByteBuf out) throws Exception
{
out.writeByte(EncryptionPacket.OPCODE);
out.writeByte(UpdateOpcodes.ENCRYPTION);
out.writeByte(encryptionPacket.getKey());
out.writeShort(0);
}

View File

@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.encoders;
package net.runelite.protocol.update.encoders;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

View File

@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.encoders;
package net.runelite.protocol.update.encoders;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@@ -31,9 +31,8 @@ import java.util.List;
import java.util.Random;
import net.runelite.cache.fs.Container;
import net.runelite.cache.fs.jagex.CompressionType;
import net.runelite.cache.fs.jagex.DataFile;
import net.runelite.cache.protocol.decoders.ArchiveResponseDecoder;
import net.runelite.cache.protocol.packets.ArchiveResponsePacket;
import net.runelite.protocol.update.decoders.ArchiveResponseDecoder;
import net.runelite.protocol.api.update.ArchiveResponsePacket;
import org.junit.Assert;
import org.junit.Test;
@@ -46,9 +45,9 @@ public class ArchiveResponseEncoderTest
Random random = new Random(42L);
random.nextBytes(data);
Container container =new Container(CompressionType.NONE, -1);
Container container = new Container(CompressionType.NONE, -1);
container.compress(data, null);
byte[] compressedData = container.data;//DataFile.compress(data, CompressionType.NONE, -1, null);
byte[] compressedData = container.data;
ArchiveResponsePacket archiveResponse = new ArchiveResponsePacket();
archiveResponse.setIndex(0);

View File

@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.protocol.encoders;
package net.runelite.protocol.update.encoders;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;