From 97b7322492d1dbd3dbb69435f37434208a1d6ebd Mon Sep 17 00:00:00 2001 From: yuzuki999 Date: Fri, 19 May 2023 08:57:32 +0800 Subject: [PATCH] clear user --- limiter/conn.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/limiter/conn.go b/limiter/conn.go index fc2c879..8ce88ae 100644 --- a/limiter/conn.go +++ b/limiter/conn.go @@ -130,9 +130,11 @@ func (c *ConnLimiter) DelConnCount(user string, ip string) { // ClearOnlineIP Clear udp,icmp and other packet protocol online ip func (c *ConnLimiter) ClearOnlineIP() { - c.ip.Range(func(_, v any) bool { + c.ip.Range(func(u, v any) bool { userIp := v.(*sync.Map) + notDel := false userIp.Range(func(ip, v any) bool { + notDel = true if _, ok := v.(int); ok { if v.(int) == 1 { // clear packet ip for realtime @@ -148,6 +150,9 @@ func (c *ConnLimiter) ClearOnlineIP() { } return true }) + if !notDel { + c.ip.Delete(u) + } return true }) }