mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-09 15:40:27 +08:00
WAF支持更多动作
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -54,31 +53,19 @@ func (this *GroupAction) RunGet(params struct {
|
||||
set := v.(*firewallconfigs.HTTPFirewallRuleSet)
|
||||
|
||||
// 动作说明
|
||||
actionLinks := []maps.Map{}
|
||||
if set.Action == firewallconfigs.HTTPFirewallActionGoGroup {
|
||||
nextGroup := firewallPolicy.FindRuleGroup(set.ActionOptions.GetInt64("groupId"))
|
||||
if nextGroup != nil {
|
||||
actionLinks = append(actionLinks, maps.Map{
|
||||
"name": nextGroup.Name,
|
||||
"url": "/servers/components/waf/group?firewallPolicyId=" + strconv.FormatInt(params.FirewallPolicyId, 10) + "&type=" + params.Type + "&groupId=" + strconv.FormatInt(nextGroup.Id, 10),
|
||||
})
|
||||
var actionMaps = []maps.Map{}
|
||||
for _, action := range set.Actions {
|
||||
def := firewallconfigs.FindActionDefinition(action.Code)
|
||||
if def == nil {
|
||||
continue
|
||||
}
|
||||
} else if set.Action == firewallconfigs.HTTPFirewallActionGoSet {
|
||||
nextGroup := firewallPolicy.FindRuleGroup(set.ActionOptions.GetInt64("groupId"))
|
||||
if nextGroup != nil {
|
||||
actionLinks = append(actionLinks, maps.Map{
|
||||
"name": nextGroup.Name,
|
||||
"url": "/servers/components/waf/group?firewallPolicyId=" + strconv.FormatInt(params.FirewallPolicyId, 10) + "&type=" + params.Type + "&groupId=" + strconv.FormatInt(nextGroup.Id, 10),
|
||||
})
|
||||
|
||||
nextSet := nextGroup.FindRuleSet(set.ActionOptions.GetInt64("setId"))
|
||||
if nextSet != nil {
|
||||
actionLinks = append(actionLinks, maps.Map{
|
||||
"name": nextSet.Name,
|
||||
"url": "/servers/components/waf/group?firewallPolicyId=" + strconv.FormatInt(params.FirewallPolicyId, 10) + "&type=" + params.Type + "&groupId=" + strconv.FormatInt(nextGroup.Id, 10),
|
||||
})
|
||||
}
|
||||
}
|
||||
actionMaps = append(actionMaps, maps.Map{
|
||||
"code": strings.ToUpper(action.Code),
|
||||
"name": def.Name,
|
||||
"category": def.Category,
|
||||
"options": action.Options,
|
||||
})
|
||||
}
|
||||
|
||||
return maps.Map{
|
||||
@@ -95,12 +82,9 @@ func (this *GroupAction) RunGet(params struct {
|
||||
"isComposed": firewallconfigs.CheckCheckpointIsComposed(rule.Prefix()),
|
||||
}
|
||||
}),
|
||||
"isOn": set.IsOn,
|
||||
"action": strings.ToUpper(set.Action),
|
||||
"actionOptions": set.ActionOptions,
|
||||
"actionName": firewallconfigs.FindActionName(set.Action),
|
||||
"actionLinks": actionLinks,
|
||||
"connector": strings.ToUpper(set.Connector),
|
||||
"isOn": set.IsOn,
|
||||
"actions": actionMaps,
|
||||
"connector": strings.ToUpper(set.Connector),
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user