Depolarize inverted quantum

pull/83/head
Thibault Duplessis 2012-10-19 20:03:55 +02:00
parent 391c285020
commit bff2c7e983
4 changed files with 22 additions and 24 deletions

View File

@ -32,26 +32,16 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
color,
getInt("version"),
get("sri"),
ctx.me).unsafePerformIO
ctx).unsafePerformIO
}
def websocketPlayer(fullId: String) = WebSocket.async[JsValue] { req
implicit val ctx = reqToCtx(req)
get("sri").fold(
sri socket.joinPlayer(
socket.joinPlayer(
fullId,
getInt("version"),
sri,
ctx.me),
putStrLn("Round Websocket: Hijack detected on %s by %s".format(fullId, ctx)) flatMap { _
socket.joinWatcher(
fullId take 8,
"white",
getInt("version"),
"hijacked".some,
ctx.me)
}
).unsafePerformIO
get("sri"),
ctx).unsafePerformIO
}
def player(fullId: String) = Open { implicit ctx

View File

@ -57,7 +57,8 @@ final class Hub(
case IsGone(_, color) sender ! playerIsGone(color)
case Join(uid, user, version, color, owner) {
case Join(uid, user, version, color, ownerWish) {
val owner = ownerWish && !ownerExists(color)
val (enumerator, channel) = Concurrent.broadcast[JsValue]
val member = Member(channel, user, color, owner)
addMember(uid, member)
@ -87,6 +88,8 @@ final class Hub(
}
}
def ownerExists(color: Color) = ownerOf(color).isDefined
def crowdEvent = Event.Crowd(
white = ownerOf(White).isDefined,
black = ownerOf(Black).isDefined,

View File

@ -20,6 +20,7 @@ import socket.{ PingVersion, Quit, Resync }
import socket.Util.connectionFail
import security.Flood
import implicits.RichJs._
import http.Context
final class Socket(
getWatcherPov: (String, String) IO[Option[Pov]],
@ -111,15 +112,15 @@ final class Socket(
colorName: String,
version: Option[Int],
uid: Option[String],
user: Option[User]): IO[SocketPromise] =
getWatcherPov(gameId, colorName) map { join(_, false, version, uid, user) }
ctx: Context): IO[SocketPromise] =
getWatcherPov(gameId, colorName) map { join(_, false, version, uid, ctx) }
def joinPlayer(
fullId: String,
version: Option[Int],
uid: String,
user: Option[User]): IO[SocketPromise] =
getPlayerPov(fullId) map { join(_, true, version, uid.some, user) }
uid: Option[String],
ctx: Context): IO[SocketPromise] =
getPlayerPov(fullId) map { join(_, true, version, uid, ctx) }
private def parseMove(event: JsValue) = for {
d event obj "d"
@ -135,25 +136,27 @@ final class Socket(
owner: Boolean,
versionOption: Option[Int],
uidOption: Option[String],
user: Option[User]): SocketPromise =
ctx: Context): SocketPromise =
((povOption |@| uidOption |@| versionOption) apply {
(pov: Pov, uid: String, version: Int)
(for {
hub hubMaster ? GetHub(pov.gameId) mapTo manifest[ActorRef]
socket hub ? Join(
uid = uid,
user = user,
user = ctx.me,
version = version,
color = pov.color,
owner = owner
) map {
case Connected(enumerator, member) (
Iteratee.foreach[JsValue](
case Connected(enumerator, member) {
if (owner && !member.owner) println("Websocket hijacking detected! " + ctx.toString)
(Iteratee.foreach[JsValue](
controller(hub, uid, member, PovRef(pov.gameId, member.color))
) mapDone { _
hub ! Quit(uid)
},
enumerator)
}
}
} yield socket).asPromise: SocketPromise
}) | connectionFail

2
todo
View File

@ -49,5 +49,7 @@ lsof show the open websockets on prod. The recurrent bug could come from the ope
lobby game filters http://en.lichess.org/forum/lichess-feedback/feature-request-game-filter#2
not possible to copy the link URL invite when using a iOS device. Can this be easily fixed by adding an automatic "copy" button next to the link?
search bug http://en.lichess.org/games/search?players.a=&players.b=&players.winner=&eloMin=&eloMax=&hasAi=&aiLevelMin=&aiLevelMax=&variant=&mode=1&opening=&turnsMin=&turnsMax=&durationMin=&durationMax=&status=35&dateMin=&dateMax=&sort.field=tu&sort.order=asc
takeback substract time for person granting
computer analysis reproducible failure http://en.lichess.org/analyse/3xr4jf80/black
detect added script and push it to server logs