From 675ef9b32fcdcc635e350e80d0196251c30dccc1 Mon Sep 17 00:00:00 2001 From: ShiKhu Date: Sat, 7 Aug 2021 17:01:13 +0800 Subject: [PATCH] fix (backend-http): sampleRate check only if starting the new one --- backend/services/http/handlers.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/services/http/handlers.go b/backend/services/http/handlers.go index b3527ac3f..761aab764 100644 --- a/backend/services/http/handlers.go +++ b/backend/services/http/handlers.go @@ -66,15 +66,15 @@ func startSessionHandlerWeb(w http.ResponseWriter, r *http.Request) { return } - dice := byte(rand.Intn(100)) // [0, 100) - if dice >= p.SampleRate { - responseWithError(w, http.StatusForbidden, errors.New("cancel")) - return - } - userUUID := getUUID(req.UserUUID) tokenData, err := tokenizer.Parse(req.Token) if err != nil || req.Reset { // Starting the new one + dice := byte(rand.Intn(100)) // [0, 100) + if dice >= p.SampleRate { + responseWithError(w, http.StatusForbidden, errors.New("cancel")) + return + } + ua := uaParser.ParseFromHTTPRequest(r) if ua == nil { responseWithError(w, http.StatusForbidden, errors.New("browser not recognized"))