From 2e032cfbab74218769ee8d040f11d3a2ad567cb4 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Wed, 12 Aug 2015 11:46:44 +0200 Subject: [PATCH] log slow processing of the fingerprint --- app/controllers/Auth.scala | 5 +++-- conf/routes | 2 +- public/javascripts/big.js | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/Auth.scala b/app/controllers/Auth.scala index c8aa883677..ce96790be8 100644 --- a/app/controllers/Auth.scala +++ b/app/controllers/Auth.scala @@ -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 } diff --git a/conf/routes b/conf/routes index 56e12941a2..15197d1354 100644 --- a/conf/routes +++ b/conf/routes @@ -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) diff --git a/public/javascripts/big.js b/public/javascripts/big.js index 2979230807..cfcb25e7f4 100644 --- a/public/javascripts/big.js +++ b/public/javascripts/big.js @@ -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); });