Add separate Protocol for INIT_JS5REMOTE_CONNECTION responses

This allows us to deal with a single corner case of the same opcode
being used for two slightly different login response packets, depending
on the request.
Graham 2 years ago
parent e90513aa36
commit 0c2108d750
  1. 2
      archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelInitializer.kt
  2. 5
      game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt
  3. 15
      protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt

@ -12,7 +12,7 @@ public class OsrsJs5ChannelInitializer(private val handler: OsrsJs5ChannelHandle
ch.pipeline().addLast(
ReadTimeoutHandler(30),
Rs2Encoder(Protocol.LOGIN_UPSTREAM),
Rs2Decoder(Protocol.LOGIN_DOWNSTREAM)
Rs2Decoder(Protocol.LOGIN_DOWNSTREAM_JS5REMOTE)
)
ch.pipeline().addLast("handler", handler)
}

@ -49,6 +49,9 @@ public class LoginChannelHandler @Inject constructor(
}
private fun handleInitJs5RemoteConnection(ctx: ChannelHandlerContext, msg: LoginRequest.InitJs5RemoteConnection) {
val encoder = ctx.pipeline().get(Rs2Encoder::class.java)
encoder.protocol = Protocol.LOGIN_DOWNSTREAM_JS5REMOTE
if (msg.build != BUILD) {
ctx.write(LoginResponse.ClientOutOfDate).addListener(ChannelFutureListener.CLOSE)
return
@ -64,7 +67,7 @@ public class LoginChannelHandler @Inject constructor(
ctx.write(LoginResponse.Js5Ok).addListener { future ->
if (future.isSuccess) {
ctx.pipeline().remove(Rs2Encoder::class.java)
ctx.pipeline().remove(encoder)
ctx.pipeline().remove(this)
}
}

@ -39,12 +39,27 @@ public class Protocol(vararg codecs: PacketCodec<*>) {
RequestWorldListCodec,
InitCrossDomainConnectionCodec
)
public val LOGIN_DOWNSTREAM: Protocol = Protocol(
ClientOutOfDateCodec,
ServerFullCodec,
IpLimitCodec
)
/**
* Unfortunately the Js5Ok packet's opcode overlaps with the exchange
* session keys opcode - the only case where this happens. We therefore
* have two LOGIN_DOWNSTREAM protocols to avoid ambiguity: one for
* responses to the InitJs5RemoteConnection packet, and one for
* responses to all other login packets.
*/
public val LOGIN_DOWNSTREAM_JS5REMOTE: Protocol = Protocol(
Js5OkCodec,
ClientOutOfDateCodec,
ServerFullCodec,
IpLimitCodec
)
public val WORLD_LIST_DOWNSTREAM: Protocol = Protocol(
WorldListResponseCodec
)

Loading…
Cancel
Save