Add OSRS INIT_JS5REMOTE_CONNECTION codec

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 3 weeks ago
parent ac17d40a62
commit f472125200
  1. 5
      archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelHandler.kt
  2. 4
      archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelInitializer.kt
  3. 9
      archive/src/main/kotlin/org/openrs2/archive/cache/osrs/InitJs5RemoteConnection.kt
  4. 29
      archive/src/main/kotlin/org/openrs2/archive/cache/osrs/InitJs5RemoteConnectionCodec.kt

@ -3,7 +3,9 @@ package org.openrs2.archive.cache
import io.netty.bootstrap.Bootstrap
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelPipeline
import org.openrs2.archive.cache.osrs.InitJs5RemoteConnection
import org.openrs2.cache.MasterIndexFormat
import org.openrs2.crypto.SymmetricKey
import org.openrs2.protocol.Rs2Decoder
import org.openrs2.protocol.Rs2Encoder
import org.openrs2.protocol.js5.downstream.Js5LoginResponse
@ -12,7 +14,6 @@ import org.openrs2.protocol.js5.downstream.Js5ResponseDecoder
import org.openrs2.protocol.js5.downstream.XorDecoder
import org.openrs2.protocol.js5.upstream.Js5Request
import org.openrs2.protocol.js5.upstream.Js5RequestEncoder
import org.openrs2.protocol.login.upstream.LoginRequest
import kotlin.coroutines.Continuation
public class OsrsJs5ChannelHandler(
@ -40,7 +41,7 @@ public class OsrsJs5ChannelHandler(
maxInFlightRequests = 200
) {
override fun createInitMessage(): Any {
return LoginRequest.InitJs5RemoteConnection(buildMajor)
return InitJs5RemoteConnection(buildMajor, SymmetricKey.ZERO)
}
override fun createRequestMessage(prefetch: Boolean, archive: Int, group: Int): Any {

@ -3,18 +3,18 @@ package org.openrs2.archive.cache
import io.netty.channel.Channel
import io.netty.channel.ChannelInitializer
import io.netty.handler.timeout.ReadTimeoutHandler
import org.openrs2.archive.cache.osrs.InitJs5RemoteConnectionCodec
import org.openrs2.protocol.Protocol
import org.openrs2.protocol.Rs2Decoder
import org.openrs2.protocol.Rs2Encoder
import org.openrs2.protocol.js5.downstream.Js5ClientOutOfDateCodec
import org.openrs2.protocol.js5.downstream.Js5OkCodec
import org.openrs2.protocol.login.upstream.InitJs5RemoteConnectionCodec
public class OsrsJs5ChannelInitializer(private val handler: OsrsJs5ChannelHandler) : ChannelInitializer<Channel>() {
override fun initChannel(ch: Channel) {
ch.pipeline().addLast(
ReadTimeoutHandler(30),
Rs2Encoder(Protocol(InitJs5RemoteConnectionCodec())),
Rs2Encoder(Protocol(InitJs5RemoteConnectionCodec)),
Rs2Decoder(Protocol(Js5OkCodec(), Js5ClientOutOfDateCodec()))
)
ch.pipeline().addLast("handler", handler)

@ -0,0 +1,9 @@
package org.openrs2.archive.cache.osrs
import org.openrs2.crypto.SymmetricKey
import org.openrs2.protocol.Packet
public data class InitJs5RemoteConnection(
public val build: Int,
public val key: SymmetricKey,
) : Packet

@ -0,0 +1,29 @@
package org.openrs2.archive.cache.osrs
import io.netty.buffer.ByteBuf
import org.openrs2.crypto.StreamCipher
import org.openrs2.crypto.SymmetricKey
import org.openrs2.protocol.FixedPacketCodec
public object InitJs5RemoteConnectionCodec : FixedPacketCodec<InitJs5RemoteConnection>(
type = InitJs5RemoteConnection::class.java,
opcode = 15,
length = 20
) {
override fun decode(input: ByteBuf, cipher: StreamCipher): InitJs5RemoteConnection {
val build = input.readInt()
val k0 = input.readInt()
val k1 = input.readInt()
val k2 = input.readInt()
val k3 = input.readInt()
return InitJs5RemoteConnection(build, SymmetricKey(k0, k1, k2, k3))
}
override fun encode(input: InitJs5RemoteConnection, output: ByteBuf, cipher: StreamCipher) {
output.writeInt(input.build)
output.writeInt(input.key.k0)
output.writeInt(input.key.k1)
output.writeInt(input.key.k2)
output.writeInt(input.key.k3)
}
}
Loading…
Cancel
Save