Improve warning response rendering

This commit is contained in:
Dominic Ferrando
2025-04-21 15:27:26 -04:00
parent 80a0a5eb89
commit da69db0492
5 changed files with 145 additions and 113 deletions
+3 -3
View File
@@ -25,16 +25,16 @@ const THREAD_COOLDOWN = 2 * time.Minute
// const THREAD_COOLDOWN = 0 * time.Minute
func IsOnCooldown(ip string, m map[string]time.Time, duration time.Duration) bool {
func IsOnCooldown(ip string, m map[string]time.Time, duration time.Duration) time.Duration {
CooldownMutex.Lock()
defer CooldownMutex.Unlock()
last, exists := m[ip]
if !exists || time.Since(last) >= duration {
m[ip] = time.Now()
return false
return time.Duration(0)
}
return true
return duration - time.Since(last)
}
func GetIP(r *http.Request) string {