mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-07 00:05:49 +08:00
IP名单优化
* 增加IP灰名单,用于仅记录并观察IP * 优化IP名单同步版本号管理 * WAF记录IP动作优先记录到网站和策略相关的IP名单中
This commit is contained in:
@@ -62,8 +62,8 @@ type IPList struct {
|
||||
id uint64
|
||||
locker sync.RWMutex
|
||||
|
||||
lastIP string // 加入到 recordIPTaskChan 之前尽可能去重
|
||||
lastTime int64
|
||||
lastIPInfo string // 加入到 recordIPTaskChan 之前尽可能去重
|
||||
lastTime int64
|
||||
}
|
||||
|
||||
// NewIPList 获取新对象
|
||||
@@ -132,11 +132,11 @@ func (this *IPList) RecordIP(ipType string,
|
||||
}
|
||||
|
||||
// 加入队列等待上传
|
||||
if this.lastIP != ip || fasttime.Now().Unix()-this.lastTime > 3 /** 3秒外才允许重复添加 **/ {
|
||||
if this.lastIPInfo != ip+"@"+ipType || fasttime.Now().Unix()-this.lastTime > 3 /** 3秒外才允许重复添加 **/ {
|
||||
select {
|
||||
case recordIPTaskChan <- &recordIPTask{
|
||||
ip: ip,
|
||||
listId: firewallconfigs.GlobalListId,
|
||||
listId: firewallconfigs.GlobalBlackListId,
|
||||
expiresAt: expiresAt,
|
||||
level: firewallconfigs.DefaultEventLevel,
|
||||
serverId: scopeServerId,
|
||||
@@ -146,7 +146,7 @@ func (this *IPList) RecordIP(ipType string,
|
||||
sourceHTTPFirewallRuleSetId: setId,
|
||||
reason: reason,
|
||||
}:
|
||||
this.lastIP = ip
|
||||
this.lastIPInfo = ip + "@" + ipType
|
||||
this.lastTime = fasttime.Now().Unix()
|
||||
default:
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user