More realistic tolerance for clock skew

This commit is contained in:
Neale Pickett 2022-06-06 15:57:03 -06:00
parent e9cbdba425
commit a3a8d9cb31
1 changed files with 2 additions and 2 deletions

View File

@ -126,11 +126,11 @@ func ChatHandler(w http.ResponseWriter, r *http.Request) {
}
// If it's wildly out of time, reject it
timeDelta := (time.Now().UnixMilli() - m.Timestamp)
timeDelta := time.Duration(time.Now().UnixMilli()-m.Timestamp) * time.Millisecond
if timeDelta < 0 {
timeDelta = -timeDelta
}
if timeDelta > 9999 {
if timeDelta > 2*time.Second {
log.Println(err)
ws.Close(websocket.StatusInvalidFramePayloadData, "Your clock is off by too much")
break