mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 18:08:14 -05:00
fix some miss
This commit is contained in:
parent
bc14e406c9
commit
c6658c2ce1
@ -9,7 +9,7 @@ type ConnLimiter struct {
|
|||||||
ipLimit int
|
ipLimit int
|
||||||
connLimit int
|
connLimit int
|
||||||
count sync.Map // map[string]int
|
count sync.Map // map[string]int
|
||||||
ip sync.Map // map[string]map[string]int or map[string]struct{}
|
ip sync.Map // map[string]map[string]int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConnLimiter(conn int, ip int) *ConnLimiter {
|
func NewConnLimiter(conn int, ip int) *ConnLimiter {
|
||||||
@ -55,10 +55,7 @@ func (c *ConnLimiter) AddConnCount(user string, ip string, isTcp bool) (limit bo
|
|||||||
ips.Store(ip, online.(int)+2)
|
ips.Store(ip, online.(int)+2)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not online ip for tcp
|
// not online ip
|
||||||
if _, ok = ips.Load(ip + "o"); ok {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
ips.Range(func(_, _ interface{}) bool {
|
ips.Range(func(_, _ interface{}) bool {
|
||||||
cn++
|
cn++
|
||||||
if cn >= c.ipLimit {
|
if cn >= c.ipLimit {
|
||||||
@ -105,7 +102,7 @@ func (c *ConnLimiter) DelConnCount(user string, ip string) {
|
|||||||
notDel := false
|
notDel := false
|
||||||
c.ip.Range(func(_, _ any) bool {
|
c.ip.Range(func(_, _ any) bool {
|
||||||
notDel = true
|
notDel = true
|
||||||
return true
|
return false
|
||||||
})
|
})
|
||||||
if !notDel {
|
if !notDel {
|
||||||
c.ip.Delete(user)
|
c.ip.Delete(user)
|
||||||
|
Loading…
Reference in New Issue
Block a user