mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-04-05 05:25:17 +08:00
集群可以设置默认的WAF策略、缓存策略
This commit is contained in:
@@ -4,9 +4,11 @@ import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -17,6 +19,7 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
LocationId int64
|
||||
}) {
|
||||
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
|
||||
@@ -28,6 +31,22 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["webId"] = webConfig.Id
|
||||
this.Data["cacheConfig"] = webConfig.Cache
|
||||
|
||||
// 当前集群的缓存策略
|
||||
cachePolicy, err := models.SharedHTTPCachePolicyDAO.FindEnabledHTTPCachePolicyWithServerId(this.AdminContext(), params.ServerId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if cachePolicy != nil {
|
||||
this.Data["cachePolicy"] = maps.Map{
|
||||
"id": cachePolicy.Id,
|
||||
"name": cachePolicy.Name,
|
||||
"isOn": cachePolicy.IsOn,
|
||||
}
|
||||
} else {
|
||||
this.Data["cachePolicy"] = nil
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package waf
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
@@ -16,6 +17,7 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ServerId int64
|
||||
LocationId int64
|
||||
}) {
|
||||
webConfig, err := webutils.FindWebConfigWithLocationId(this.Parent(), params.LocationId)
|
||||
@@ -27,22 +29,21 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["webId"] = webConfig.Id
|
||||
this.Data["firewallConfig"] = webConfig.FirewallRef
|
||||
|
||||
// 当前已有策略
|
||||
policiesResp, err := this.RPC().HTTPFirewallPolicyRPC().FindAllEnabledHTTPFirewallPolicies(this.AdminContext(), &pb.FindAllEnabledHTTPFirewallPoliciesRequest{})
|
||||
// 获取当前服务所在集群的WAF设置
|
||||
firewallPolicy, err := models.SharedHTTPFirewallPolicyDAO.FindEnabledHTTPFirewallPolicyWithServerId(this.AdminContext(), params.ServerId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
policyMaps := []maps.Map{}
|
||||
for _, p := range policiesResp.FirewallPolicies {
|
||||
policyMaps = append(policyMaps, maps.Map{
|
||||
"id": p.Id,
|
||||
"name": p.Name,
|
||||
"isOn": p.IsOn,
|
||||
"description": p.Description,
|
||||
})
|
||||
if firewallPolicy != nil {
|
||||
this.Data["firewallPolicy"] = maps.Map{
|
||||
"id": firewallPolicy.Id,
|
||||
"name": firewallPolicy.Name,
|
||||
"isOn": firewallPolicy.IsOn,
|
||||
}
|
||||
} else {
|
||||
this.Data["firewallPolicy"] = nil
|
||||
}
|
||||
this.Data["firewallPolicies"] = policyMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user