Add admin session cleanup

This commit is contained in:
Dominic Ferrando
2025-04-24 01:18:04 -04:00
parent 99f8c7f97d
commit 69f0d7d5f0
+10
View File
@@ -625,6 +625,7 @@ func main() {
defer ticker.Stop() defer ticker.Stop()
for range ticker.C { for range ticker.C {
// cleanup cooldowns
util.CooldownMutex.Lock() util.CooldownMutex.Lock()
for ip, t := range util.PostCooldowns { for ip, t := range util.PostCooldowns {
if time.Since(t) >= util.POST_COOLDOWN { if time.Since(t) >= util.POST_COOLDOWN {
@@ -637,6 +638,15 @@ func main() {
} }
} }
util.CooldownMutex.Unlock() util.CooldownMutex.Unlock()
// cleanup admin sessions
util.AdminMutex.Lock()
for token, s := range util.AdminSessions {
if time.Now().After(s.Expiration) {
delete(util.AdminSessions, token)
}
}
util.AdminMutex.Unlock()
} }
}() }()