mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
从IP名单中查询IP时增加过期时间检查,防止GC速度慢时可能有1秒延迟
This commit is contained in:
@@ -267,7 +267,7 @@ func (this *IPList) sortRangeItems(force bool) {
|
|||||||
func (this *IPList) lookupIP(ipBytes []byte) *IPItem {
|
func (this *IPList) lookupIP(ipBytes []byte) *IPItem {
|
||||||
{
|
{
|
||||||
item, ok := this.ipMap[ToHex(ipBytes)]
|
item, ok := this.ipMap[ToHex(ipBytes)]
|
||||||
if ok {
|
if ok && (item.ExpiredAt == 0 || item.ExpiredAt > fasttime.Now().Unix()) {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,11 @@ func (this *IPList) lookupIP(ipBytes []byte) *IPItem {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.sortedRangeItems[resultIndex]
|
var item = this.sortedRangeItems[resultIndex]
|
||||||
|
if item.ExpiredAt == 0 || item.ExpiredAt > fasttime.Now().Unix() {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在不加锁的情况下删除某个Item
|
// 在不加锁的情况下删除某个Item
|
||||||
|
|||||||
Reference in New Issue
Block a user