chore: fix a warning

This commit is contained in:
0x1a8510f2 2023-06-03 04:29:11 +01:00
parent 9d9fcedc8a
commit bdca38f530
Signed by: 0x1a8510f2
GPG Key ID: 1C692E355D76775D
2 changed files with 5 additions and 5 deletions

View File

@ -142,12 +142,12 @@ func ComputeTimeTokenHash(token []byte, authtime time.Time) string {
return hex.EncodeToString(hash[:])
}
func TradeTokens(c Config, reqdata authRequest) ([]byte, time.Time, authStatus, bool) {
func TradeTokens(c *Config, reqdata authRequest) ([]byte, time.Time, authStatus, bool) {
authtime := time.UnixMilli(reqdata.Time)
// Make sure that the authtime is within reasonable boundaries (10 seconds either way).
if authtime.Before(time.Now().UTC().Add(-10*time.Second)) ||
authtime.After(time.Now().UTC().Add(10*time.Second)) {
// Make sure that the authtime is within reasonable boundaries (3 seconds either way).
if authtime.Before(time.Now().UTC().Add(-3*time.Second)) ||
authtime.After(time.Now().UTC().Add(3*time.Second)) {
return []byte{}, time.Time{}, AUTH_STATUS_N, false
}

View File

@ -191,7 +191,7 @@ func main() {
}
// Validate credential.
outtoken, expiry, status, ok := TradeTokens(c, reqdata)
outtoken, expiry, status, ok := TradeTokens(&c, reqdata)
if !ok {
c.attemptsUntilLockout.Add(-1)
w.WriteHeader(http.StatusUnauthorized)