setup new websocket trap

This commit is contained in:
Thibault Duplessis 2012-10-23 01:16:21 +02:00
parent 2394da6397
commit 9293b17bb0
4 changed files with 8 additions and 4 deletions

View file

@ -43,6 +43,7 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
getInt("version"),
get("sri"),
get("tk"),
get("tr") | "-",
ctx).unsafePerformIO
}

View file

@ -120,8 +120,11 @@ final class Socket(
version: Option[Int],
uid: Option[String],
token: Option[String],
ctx: Context): IO[SocketPromise] =
trap: String,
ctx: Context): IO[SocketPromise] = {
if (trap != "a") println("[websocket] trap %s %s".format(fullId, ctx.toString))
getPlayerPov(fullId) map { join(_, true, version, uid, token, ctx) }
}
private def parseMove(event: JsValue) = for {
d event obj "d"
@ -168,7 +171,7 @@ final class Socket(
private def isHijack(pov: Pov, token: Option[String], ctx: Context) =
if (hijacks contains pov.fullId) true
else if (token != pov.game.token.some) true ~ { _
println("Websocket hijacking detected %s %s".format(pov.fullId, ctx.toString))
println("[websocket] hijacking detected %s %s".format(pov.fullId, ctx.toString))
hijacks += pov.fullId
}
else false

View file

@ -7,7 +7,7 @@ import play.api.templates.Html
trait AssetHelper {
val assetVersion = 8
val assetVersion = 9
def cssTag(name: String) = css("stylesheets/" + name)

View file

@ -571,7 +571,7 @@ $.widget("lichess.game", {
options: {
name: "game"
},
params: { tk: "--tkph--"},
params: { tk: "--tkph--", tr: "a"},
events: {
ack: function() {
clearTimeout(self.socketAckTimeout);