Block动作增加默认时间60秒

This commit is contained in:
GoEdgeLab
2021-09-29 09:19:45 +08:00
parent 1afb5dfcc7
commit f06d3cacb3
7 changed files with 34 additions and 7 deletions
+5 -3
View File
@@ -57,10 +57,12 @@ func (this *BlockAction) WillChange() bool {
}
func (this *BlockAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, request requests.Request, writer http.ResponseWriter) (allow bool) {
if this.Timeout > 0 {
// 加入到黑名单
SharedIPBlackLIst.Add(IPTypeAll, request.WAFRemoteIP(), time.Now().Unix()+int64(this.Timeout))
// 加入到黑名单
var timeout = this.Timeout
if timeout <= 0 {
timeout = 60 // 默认封锁60秒
}
SharedIPBlackList.Add(IPTypeAll, request.WAFRemoteIP(), time.Now().Unix()+int64(timeout))
if writer != nil {
// close the connection
+1 -1
View File
@@ -92,7 +92,7 @@ func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, re
if this.Type == "black" {
_ = this.CloseConn(writer)
SharedIPBlackLIst.Add(IPTypeAll, request.WAFRemoteIP(), expiredAt)
SharedIPBlackList.Add(IPTypeAll, request.WAFRemoteIP(), expiredAt)
} else {
// 加入本地白名单
timeout := this.Timeout
+1 -1
View File
@@ -9,7 +9,7 @@ import (
)
var SharedIPWhiteList = NewIPList()
var SharedIPBlackLIst = NewIPList()
var SharedIPBlackList = NewIPList()
const IPTypeAll = "*"