fishnet key check endpoint
parent
d67e1ba9a7
commit
62c7ca8149
|
@ -17,10 +17,6 @@ object Fishnet extends LilaController {
|
|||
private def api = env.api
|
||||
override val logger = lila.log("fishnet")
|
||||
|
||||
def clientIp(req: RequestHeader) = lila.fishnet.Client.IpAddress {
|
||||
HTTPRequest lastRemoteAddress req
|
||||
}
|
||||
|
||||
def acquire = ClientAction[JsonApi.Request.Acquire] { req =>
|
||||
client =>
|
||||
api acquire client
|
||||
|
@ -41,6 +37,13 @@ object Fishnet extends LilaController {
|
|||
api.abort(Work.Id(workId), client) inject none
|
||||
}
|
||||
|
||||
def keyExists(key: String) = Action.async { req =>
|
||||
api keyExists lila.fishnet.Client.Key(key) map {
|
||||
case true => Ok
|
||||
case false => NotFound
|
||||
}
|
||||
}
|
||||
|
||||
private def ClientAction[A <: JsonApi.Request](f: A => lila.fishnet.Client => Fu[Option[JsonApi.Work]])(implicit reads: Reads[A]) =
|
||||
Action.async(BodyParsers.parse.tolerantJson) { req =>
|
||||
req.body.validate[A].fold(
|
||||
|
@ -60,4 +63,8 @@ object Fishnet extends LilaController {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
private def clientIp(req: RequestHeader) = lila.fishnet.Client.IpAddress {
|
||||
HTTPRequest lastRemoteAddress req
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,6 +213,7 @@ POST /fishnet/acquire controllers.Fishnet.acquire
|
|||
POST /fishnet/move/$workId<\w{8}> controllers.Fishnet.move(workId: String)
|
||||
POST /fishnet/analysis/$workId<\w{8}> controllers.Fishnet.analysis(workId: String)
|
||||
POST /fishnet/abort/$workId<\w{8}> controllers.Fishnet.abort(workId: String)
|
||||
GET /fishnet/key/$key<\w{8}> controllers.Fishnet.keyExists(key: String)
|
||||
|
||||
# Pref
|
||||
POST /pref/:name controllers.Pref.set(name: String)
|
||||
|
|
|
@ -24,6 +24,8 @@ final class FishnetApi(
|
|||
import FishnetApi._
|
||||
import BSONHandlers._
|
||||
|
||||
def keyExists(key: Client.Key) = repo.getEnabledClient(key).map(_.isDefined)
|
||||
|
||||
def authenticateClient(req: JsonApi.Request, ip: Client.IpAddress): Fu[Try[Client]] = {
|
||||
if (offlineMode) repo.getOfflineClient map some
|
||||
else repo.getEnabledClient(req.fishnet.apikey)
|
||||
|
|
Loading…
Reference in New Issue