mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-18 23:10:25 +08:00
实现WAF部分功能
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package waf
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type DeleteGroupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteGroupAction) RunPost(params struct {
|
||||
FirewallPolicyId int64
|
||||
GroupId int64
|
||||
}) {
|
||||
firewallPolicy, err := models.SharedHTTPFirewallPolicyDAO.FindEnabledPolicyConfig(this.AdminContext(), params.FirewallPolicyId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
if firewallPolicy == nil {
|
||||
this.NotFound("firewallPolicy", params.FirewallPolicyId)
|
||||
return
|
||||
}
|
||||
firewallPolicy.RemoveRuleGroup(params.GroupId)
|
||||
|
||||
inboundJSON, err := firewallPolicy.InboundJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
outboundJSON, err := firewallPolicy.OutboundJSON()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().HTTPFirewallPolicyRPC().UpdateHTTPFirewallPolicyGroups(this.AdminContext(), &pb.UpdateHTTPFirewallPolicyGroupsRequest{
|
||||
FirewallPolicyId: params.FirewallPolicyId,
|
||||
InboundJSON: inboundJSON,
|
||||
OutboundJSON: outboundJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user