add delay task1 answer check

main
Nikita Tokarchuk 4 years ago
parent 3b716f63ca
commit 86eceeeba5
  1. 3
      task1-backend/lib/api.go

@ -7,6 +7,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"math/rand"
"net/http"
"regexp"
"strings"
@ -100,6 +101,8 @@ func (a *Api) checkAnswer(ctx *routing.Context) (err error) {
log.Debugf("req answer, %v", answer)
log.Debugf("req hashed, %s", hexed)
time.Sleep(time.Second + (time.Millisecond * time.Duration(rand.Intn(500))))
valid := subtle.ConstantTimeCompare(a.Answer, hexed)
if valid == 0 {
return routing.NewHTTPError(http.StatusForbidden)

Loading…
Cancel
Save