mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 20:30:25 +08:00
实现WAF部分功能
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package waf
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||
)
|
||||
|
||||
type DeleteSetAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteSetAction) RunPost(params struct {
|
||||
GroupId int64
|
||||
SetId int64
|
||||
}) {
|
||||
groupConfig, err := models.SharedHTTPFirewallRuleGroupDAO.FindRuleGroupConfig(this.AdminContext(), params.GroupId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if groupConfig == nil {
|
||||
this.NotFound("firewallRuleGroup", params.GroupId)
|
||||
return
|
||||
}
|
||||
|
||||
newRefs := []*firewallconfigs.HTTPFirewallRuleSetRef{}
|
||||
for _, ref := range groupConfig.SetRefs {
|
||||
if ref.SetId != params.SetId {
|
||||
newRefs = append(newRefs, ref)
|
||||
}
|
||||
}
|
||||
newRefsJSON, err := json.Marshal(newRefs)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
_, err = this.RPC().HTTPFirewallRuleGroupRPC().UpdateHTTPFirewallRuleGroupSets(this.AdminContext(), &pb.UpdateHTTPFirewallRuleGroupSetsRequest{
|
||||
FirewallRuleGroupId: params.GroupId,
|
||||
FirewallRuleSetsJSON: newRefsJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user