diff --git a/accounts/accountManager.go b/accounts/accountManager.go index 75840f0..de0b700 100644 --- a/accounts/accountManager.go +++ b/accounts/accountManager.go @@ -210,11 +210,12 @@ func (a *AccountManager) AccountExists(username string) bool { func (a *AccountManager) IsValidAccount(username string) (bool, error) { for x := range a.accounts { if a.accounts[x].Username == username { - time24hrAgo := time.Now().Add(-24 * time.Hour).Unix() - timeNow := time.Now().Unix() + timeNow := time.Now() + timeNowUnix := timeNow.Unix() + time24hrAgo := timeNow.Add(-24 * time.Hour).Unix() return !(a.accounts[x].Suspended || a.accounts[x].Banned || - int64(a.accounts[x].WarnExpiration) > timeNow || + int64(a.accounts[x].WarnExpiration) > timeNowUnix || (a.accounts[x].LastDisabled.Valid && a.accounts[x].LastDisabled.Int64 > time24hrAgo)), nil } } @@ -273,7 +274,6 @@ func (a *AccountManager) MarkDisabled(username string) { for x := range a.accounts { if a.accounts[x].Username == username { - a.accounts[x].LastDisabled = null.IntFrom(time.Now().Unix()) } } diff --git a/routes/raw.go b/routes/raw.go index b326482..1854939 100644 --- a/routes/raw.go +++ b/routes/raw.go @@ -101,10 +101,11 @@ func Raw(c *gin.Context) { } } if ws.CheckLimitExceeded() { - log.Warnf("[RAW] [%s] Account would exceed soft limits - DISABLED ACCOUNT: [%s]", res.Uuid, res.Username) - accountManager.MarkDisabled(res.Username) - counts := ws.RequestCounts() - log.Infof("[RAW] [%s] [%s] Account limits: %v", res.Uuid, res.Username, counts) + log.Warnf("[RAW] [%s] [%s] Account would exceed soft limits - DISABLED ACCOUNT", res.Uuid, res.Username) + if isValid, _ := accountManager.IsValidAccount(res.Username); isValid { + accountManager.MarkDisabled(res.Username) + } + log.Infof("[RAW] [%s] [%s] Account limits: %v", res.Uuid, res.Username, ws.RequestCounts()) } }() }