mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-04-22 18:55:18 +08:00
IP名单改成同时检查多个IP来源
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package iplibrary
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/expires"
|
||||
"sync"
|
||||
)
|
||||
@@ -108,6 +109,30 @@ func (this *IPList) Contains(ip uint64) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
// 是否包含一组IP
|
||||
func (this *IPList) ContainsIPStrings(ipStrings []string) bool {
|
||||
if len(ipStrings) == 0 {
|
||||
return false
|
||||
}
|
||||
this.locker.RLock()
|
||||
if this.isAll {
|
||||
this.locker.RUnlock()
|
||||
return true
|
||||
}
|
||||
for _, ipString := range ipStrings {
|
||||
if len(ipString) == 0 {
|
||||
continue
|
||||
}
|
||||
_, ok := this.ipMap[utils.IP2Long(ipString)]
|
||||
if ok {
|
||||
this.locker.RUnlock()
|
||||
return true
|
||||
}
|
||||
}
|
||||
this.locker.RUnlock()
|
||||
return false
|
||||
}
|
||||
|
||||
// 在不加锁的情况下删除某个Item
|
||||
// 将会被别的方法引用,切记不能加锁
|
||||
func (this *IPList) deleteItem(itemId int64) {
|
||||
|
||||
Reference in New Issue
Block a user