clear user

This commit is contained in:
yuzuki999 2023-05-19 08:57:32 +08:00
parent 8890b566d5
commit 97b7322492

View File

@ -130,9 +130,11 @@ func (c *ConnLimiter) DelConnCount(user string, ip string) {
// ClearOnlineIP Clear udp,icmp and other packet protocol online ip // ClearOnlineIP Clear udp,icmp and other packet protocol online ip
func (c *ConnLimiter) ClearOnlineIP() { func (c *ConnLimiter) ClearOnlineIP() {
c.ip.Range(func(_, v any) bool { c.ip.Range(func(u, v any) bool {
userIp := v.(*sync.Map) userIp := v.(*sync.Map)
notDel := false
userIp.Range(func(ip, v any) bool { userIp.Range(func(ip, v any) bool {
notDel = true
if _, ok := v.(int); ok { if _, ok := v.(int); ok {
if v.(int) == 1 { if v.(int) == 1 {
// clear packet ip for realtime // clear packet ip for realtime
@ -148,6 +150,9 @@ func (c *ConnLimiter) ClearOnlineIP() {
} }
return true return true
}) })
if !notDel {
c.ip.Delete(u)
}
return true return true
}) })
} }