update conf, fix tcp count

This commit is contained in:
yuzuki999
2023-05-19 09:49:31 +08:00
parent 97b7322492
commit 179de8ab2a
6 changed files with 57 additions and 43 deletions

View File

@@ -3,6 +3,7 @@ package limiter
import (
"sync"
"testing"
"time"
)
var c *ConnLimiter
@@ -23,13 +24,21 @@ func TestConnLimiter_DelConnCount(t *testing.T) {
t.Log(c.AddConnCount("1", "2", true))
}
func TestConnLimiter_ClearPacketOnlineIP(t *testing.T) {
func TestConnLimiter_ClearOnlineIP(t *testing.T) {
t.Log(c.AddConnCount("1", "1", false))
t.Log(c.AddConnCount("1", "2", false))
c.ClearOnlineIP()
t.Log(c.AddConnCount("1", "2", true))
c.DelConnCount("1", "2")
t.Log(c.AddConnCount("1", "1", false))
// not realtime
c.realtime = false
t.Log(c.AddConnCount("3", "2", true))
c.ClearOnlineIP()
t.Log(c.ip.Load("3"))
time.Sleep(time.Minute)
c.ClearOnlineIP()
t.Log(c.ip.Load("3"))
}
func BenchmarkConnLimiter(b *testing.B) {