github.com/TeaOSLab/EdgeNode@v1.3.8/internal/nodes/client_conn_limiter_test.go (about) 1 // Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. 2 3 package nodes 4 5 import ( 6 "github.com/iwind/TeaGo/logs" 7 "testing" 8 ) 9 10 func TestClientConnLimiter_Add(t *testing.T) { 11 var limiter = NewClientConnLimiter() 12 { 13 b := limiter.Add("127.0.0.1:1234", 1, "192.168.1.100", 10, 5) 14 t.Log(b) 15 } 16 { 17 b := limiter.Add("127.0.0.1:1235", 1, "192.168.1.100", 10, 5) 18 t.Log(b) 19 } 20 { 21 b := limiter.Add("127.0.0.1:1236", 1, "192.168.1.100", 10, 5) 22 t.Log(b) 23 } 24 { 25 b := limiter.Add("127.0.0.1:1237", 1, "192.168.1.101", 10, 5) 26 t.Log(b) 27 } 28 { 29 b := limiter.Add("127.0.0.1:1238", 1, "192.168.1.100", 5, 5) 30 t.Log(b) 31 } 32 limiter.Remove("127.0.0.1:1238") 33 limiter.Remove("127.0.0.1:1239") 34 limiter.Remove("127.0.0.1:1237") 35 logs.PrintAsJSON(limiter.remoteAddrMap, t) 36 logs.PrintAsJSON(limiter.ipConns, t) 37 logs.PrintAsJSON(limiter.serverConns, t) 38 }