fix(lib): fix invalid response after success in Chrome (#711)
Closes #564 This one is really dumb. Take a seat and listen to my tale of woe. While @victorvalenca was working on #693 we ran into a strange issue. The tests would consistently pass on Firefox but instantly failed on Chrome. After adding increasingly desperate debugging logs to the mix, we found out that somehow Chrome was randomizing the contents of its Accept-Language header. This was making the challenge string get calculated differently, thus making things spuriously fail. I cannot figure out what causes Chrome to do this other than you being in an environment where you have more than one "system language" set. Either way, this should finally fix this issue and bring peace to the land forever*. Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
8c79870edb
commit
16a4e04027
2 changed files with 2 additions and 7 deletions
|
|
@ -77,14 +77,8 @@ type Server struct {
|
|||
func (s *Server) challengeFor(r *http.Request, difficulty int) string {
|
||||
fp := sha256.Sum256(s.pub[:])
|
||||
|
||||
acceptLanguage := r.Header.Get("Accept-Language")
|
||||
if len(acceptLanguage) > 5 {
|
||||
acceptLanguage = acceptLanguage[:5]
|
||||
}
|
||||
|
||||
challengeData := fmt.Sprintf(
|
||||
"Accept-Language=%s,X-Real-IP=%s,User-Agent=%s,WeekTime=%s,Fingerprint=%x,Difficulty=%d",
|
||||
acceptLanguage,
|
||||
"X-Real-IP=%s,User-Agent=%s,WeekTime=%s,Fingerprint=%x,Difficulty=%d",
|
||||
r.Header.Get("X-Real-Ip"),
|
||||
r.UserAgent(),
|
||||
time.Now().UTC().Round(24*7*time.Hour).Format(time.RFC3339),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue