log slow processing of the fingerprint

pull/781/head
Thibault Duplessis 2015-08-12 11:46:44 +02:00
parent cef4d5bc2e
commit 2e032cfbab
3 changed files with 7 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import play.api.Play.current
import lila.api.Context
import lila.app._
import lila.common.LilaCookie
import lila.common.{ LilaCookie, HTTPRequest }
import lila.user.{ UserRepo, User => UserModel }
import views._
@ -155,8 +155,9 @@ object Auth extends LilaController {
html = Unauthorized(html.auth.tor()).fuccess,
api = _ => Unauthorized(Json.obj("error" -> "Can't login from TOR, sorry!")).fuccess)
def setFingerprint(hash: String) = Auth { ctx =>
def setFingerprint(hash: String, ms: Int) = Auth { ctx =>
me =>
if (ms > 1000) logwarn(s"[Fingerprint] ${me.username} $ms ms / ${~HTTPRequest.userAgent(ctx.req)}")
api.setFingerprint(ctx.req, hash) inject Ok
}

View File

@ -234,7 +234,7 @@ POST /password/reset/send controllers.Auth.passwordResetApply
GET /password/reset/sent/:email controllers.Auth.passwordResetSent(email: String)
GET /password/reset/confirm/:token controllers.Auth.passwordResetConfirm(token: String)
POST /password/reset/confirm/:token controllers.Auth.passwordResetConfirmApply(token: String)
POST /set-fingerprint/:hash controllers.Auth.setFingerprint(hash: String)
POST /set-fingerprint/:hash/:ms controllers.Auth.setFingerprint(hash: String, ms: Int)
# Mod
POST /mod/:username/engine controllers.Mod.engine(username: String)

View File

@ -1049,10 +1049,12 @@ lichess.storage = {
});
if (window.Fingerprint2) setTimeout(function() {
var t = +new Date();
new Fingerprint2({
excludeJsFonts: true
}).get(function(res) {
$.post('/set-fingerprint/' + res);
var time = (+new Date()) - t;
$.post('/set-fingerprint/' + res + '/' + time);
});
}, 500);
});