API: Add user IPs and access times tracking (#4360)

This commit is contained in:
Maxim Plotnikov 2025-02-07 07:19:47 -05:00 committed by GitHub
parent 1982c2366e
commit e893fa1828
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 263 additions and 62 deletions

View file

@ -78,3 +78,13 @@ func (c *OnlineMap) RemoveExpiredIPs(list map[string]time.Time) map[string]time.
}
return list
}
func (c *OnlineMap) IpTimeMap() map[string]time.Time {
list := c.ipList
if time.Since(c.lastCleanup) > c.cleanupPeriod {
list = c.RemoveExpiredIPs(list)
c.lastCleanup = time.Now()
}
return c.ipList
}