mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-03-06 16:15:38 +08:00
优化删除IP名单时操作
This commit is contained in:
30
internal/waf/ip_lists_deleted.go
Normal file
30
internal/waf/ip_lists_deleted.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package waf
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/zero"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var deletedIPListIdMap = map[int64]zero.Zero{} // listId => Zero
|
||||
var deletedIPListLocker = sync.RWMutex{}
|
||||
|
||||
// AddDeletedIPList add deleted ip list
|
||||
func AddDeletedIPList(ipListId int64) {
|
||||
if ipListId <= 0 {
|
||||
return
|
||||
}
|
||||
|
||||
deletedIPListLocker.Lock()
|
||||
deletedIPListIdMap[ipListId] = zero.Zero{}
|
||||
deletedIPListLocker.Unlock()
|
||||
}
|
||||
|
||||
// ExistDeletedIPList check if ip list has been deleted
|
||||
func ExistDeletedIPList(ipListId int64) bool {
|
||||
deletedIPListLocker.RLock()
|
||||
_, ok := deletedIPListIdMap[ipListId]
|
||||
deletedIPListLocker.RUnlock()
|
||||
return ok
|
||||
}
|
||||
Reference in New Issue
Block a user