mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-28 19:20:25 +08:00
WAF记录IP动作中IP名单如果为空时,默认为全局黑名单
This commit is contained in:
@@ -133,8 +133,13 @@ func (this *RecordIPAction) WillChange() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, request requests.Request, writer http.ResponseWriter) (continueRequest bool, goNextSet bool) {
|
func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, request requests.Request, writer http.ResponseWriter) (continueRequest bool, goNextSet bool) {
|
||||||
|
var ipListId = this.IPListId
|
||||||
|
if ipListId <= 0 {
|
||||||
|
ipListId = firewallconfigs.GlobalListId
|
||||||
|
}
|
||||||
|
|
||||||
// 是否已删除
|
// 是否已删除
|
||||||
var ipListIsAvailable = this.IPListId > 0 && !this.IPListIsDeleted && !ExistDeletedIPList(this.IPListId)
|
var ipListIsAvailable = (ipListId == firewallconfigs.GlobalListId) || (ipListId > 0 && !this.IPListIsDeleted && !ExistDeletedIPList(ipListId))
|
||||||
|
|
||||||
// 是否在本地白名单中
|
// 是否在本地白名单中
|
||||||
if SharedIPWhiteList.Contains("set:"+types.String(set.Id), this.Scope, request.WAFServerId(), request.WAFRemoteIP()) {
|
if SharedIPWhiteList.Contains("set:"+types.String(set.Id), this.Scope, request.WAFServerId(), request.WAFRemoteIP()) {
|
||||||
@@ -167,7 +172,7 @@ func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 上报
|
// 上报
|
||||||
if this.IPListId > 0 && ipListIsAvailable {
|
if ipListId > 0 && ipListIsAvailable {
|
||||||
var serverId int64
|
var serverId int64
|
||||||
if this.Scope == firewallconfigs.FirewallScopeService {
|
if this.Scope == firewallconfigs.FirewallScopeService {
|
||||||
serverId = request.WAFServerId()
|
serverId = request.WAFServerId()
|
||||||
@@ -181,7 +186,7 @@ func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, re
|
|||||||
select {
|
select {
|
||||||
case recordIPTaskChan <- &recordIPTask{
|
case recordIPTaskChan <- &recordIPTask{
|
||||||
ip: request.WAFRemoteIP(),
|
ip: request.WAFRemoteIP(),
|
||||||
listId: this.IPListId,
|
listId: ipListId,
|
||||||
expiresAt: realExpiresAt,
|
expiresAt: realExpiresAt,
|
||||||
level: this.Level,
|
level: this.Level,
|
||||||
serverId: serverId,
|
serverId: serverId,
|
||||||
|
|||||||
Reference in New Issue
Block a user