mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-01 19:16:35 +08:00
实现WAF
This commit is contained in:
37
internal/waf/action_go_set.go
Normal file
37
internal/waf/action_go_set.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package waf
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type GoSetAction struct {
|
||||
GroupId string `yaml:"groupId" json:"groupId"`
|
||||
SetId string `yaml:"setId" json:"setId"`
|
||||
}
|
||||
|
||||
func (this *GoSetAction) Perform(waf *WAF, request *requests.Request, writer http.ResponseWriter) (allow bool) {
|
||||
group := waf.FindRuleGroup(this.GroupId)
|
||||
if group == nil || !group.IsOn {
|
||||
return true
|
||||
}
|
||||
set := group.FindRuleSet(this.SetId)
|
||||
if set == nil || !set.IsOn {
|
||||
return true
|
||||
}
|
||||
|
||||
b, err := set.MatchRequest(request)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
return true
|
||||
}
|
||||
if !b {
|
||||
return true
|
||||
}
|
||||
actionObject := FindActionInstance(set.Action, set.ActionOptions)
|
||||
if actionObject == nil {
|
||||
return true
|
||||
}
|
||||
return actionObject.Perform(waf, request, writer)
|
||||
}
|
||||
Reference in New Issue
Block a user