From a3a8d9cb311280ce50ab113a2f201cadddb11b8f Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 6 Jun 2022 15:57:03 -0600 Subject: [PATCH] More realistic tolerance for clock skew --- cmd/vail/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/vail/main.go b/cmd/vail/main.go index 3d66079..e94e0c3 100644 --- a/cmd/vail/main.go +++ b/cmd/vail/main.go @@ -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