Close JS5 connection if an invalid file is requested

This mimics the behaviour of the OSRS server.

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent f48d23c4b9
commit fbb9694feb
  1. 6
      game/src/main/kotlin/org/openrs2/game/net/js5/Js5Service.kt

@ -12,6 +12,7 @@ import org.openrs2.cache.VersionTrailer
import org.openrs2.protocol.js5.Js5Request import org.openrs2.protocol.js5.Js5Request
import org.openrs2.protocol.js5.Js5Response import org.openrs2.protocol.js5.Js5Response
import org.openrs2.util.collect.UniqueQueue import org.openrs2.util.collect.UniqueQueue
import java.io.FileNotFoundException
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -66,6 +67,7 @@ public class Js5Service @Inject constructor(
} }
} }
} else { } else {
try {
store.read(request.archive, request.group).use { buf -> store.read(request.archive, request.group).use { buf ->
if (request.archive != Js5Archive.ARCHIVESET) { if (request.archive != Js5Archive.ARCHIVESET) {
VersionTrailer.strip(buf) VersionTrailer.strip(buf)
@ -73,6 +75,10 @@ public class Js5Service @Inject constructor(
buf.retain() buf.retain()
} }
} catch (ex: FileNotFoundException) {
ctx.close()
return
}
} }
val response = Js5Response(request.prefetch, request.archive, request.group, buf) val response = Js5Response(request.prefetch, request.archive, request.group, buf)

Loading…
Cancel
Save