only record tcp connecting ip on real time

This commit is contained in:
yuzuki999
2023-05-17 00:56:14 +08:00
parent 49cdbbbaa4
commit bc14e406c9
6 changed files with 95 additions and 27 deletions

View File

@@ -12,15 +12,24 @@ func init() {
}
func TestConnLimiter_AddConnCount(t *testing.T) {
t.Log(c.AddConnCount("1", "1"))
t.Log(c.AddConnCount("1", "2"))
t.Log(c.AddConnCount("1", "1", true))
t.Log(c.AddConnCount("1", "2", true))
}
func TestConnLimiter_DelConnCount(t *testing.T) {
t.Log(c.AddConnCount("1", "1"))
t.Log(c.AddConnCount("1", "2"))
t.Log(c.AddConnCount("1", "1", true))
t.Log(c.AddConnCount("1", "2", true))
c.DelConnCount("1", "1")
t.Log(c.AddConnCount("1", "2"))
t.Log(c.AddConnCount("1", "2", true))
}
func TestConnLimiter_ClearPacketOnlineIP(t *testing.T) {
t.Log(c.AddConnCount("1", "1", false))
t.Log(c.AddConnCount("1", "2", false))
c.ClearPacketOnlineIP()
t.Log(c.AddConnCount("1", "2", true))
c.DelConnCount("1", "2")
t.Log(c.AddConnCount("1", "1", false))
}
func BenchmarkConnLimiter(b *testing.B) {
@@ -28,7 +37,7 @@ func BenchmarkConnLimiter(b *testing.B) {
for i := 0; i < b.N; i++ {
wg.Add(1)
go func() {
c.AddConnCount("1", "2")
c.AddConnCount("1", "2", true)
c.DelConnCount("1", "2")
wg.Done()
}()