diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelInitializer.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelInitializer.kt index 7c53c615..53845962 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelInitializer.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelInitializer.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) } diff --git a/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt b/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt index 94f00d38..f52b986d 100644 --- a/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt +++ b/game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt @@ -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) } } diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt b/protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt index ce703b6b..9de48685 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/Protocol.kt @@ -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 )