1.5.0
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
nodethresholds "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/settings/thresholds"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/cc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/http3"
|
||||
networksecurity "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/network-security"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/pages"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/thresholds"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/uam"
|
||||
@@ -53,7 +52,6 @@ func init() {
|
||||
GetPost("/thresholds", new(thresholds.IndexAction)).
|
||||
|
||||
//
|
||||
GetPost("/network-security", new(networksecurity.IndexAction)).
|
||||
|
||||
// 节点设置相关
|
||||
Prefix("/clusters/cluster/node/settings").
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build plus
|
||||
|
||||
package networksecurity
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "setting", "index")
|
||||
this.SecondMenu("networkSecurity")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
policyResp, err := this.RPC().NodeClusterRPC().FindNodeClusterNetworkSecurityPolicy(this.AdminContext(), &pb.FindNodeClusterNetworkSecurityPolicyRequest{
|
||||
NodeClusterId: params.ClusterId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var policy = nodeconfigs.NewNetworkSecurityPolicy()
|
||||
if len(policyResp.NetworkSecurityPolicyJSON) > 0 {
|
||||
err = json.Unmarshal(policyResp.NetworkSecurityPolicyJSON, policy)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.Data["policy"] = policy
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ClusterId int64
|
||||
Status string
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
policyResp, err := this.RPC().NodeClusterRPC().FindNodeClusterNetworkSecurityPolicy(this.AdminContext(), &pb.FindNodeClusterNetworkSecurityPolicyRequest{
|
||||
NodeClusterId: params.ClusterId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var policy = nodeconfigs.NewNetworkSecurityPolicy()
|
||||
if len(policyResp.NetworkSecurityPolicyJSON) > 0 {
|
||||
err = json.Unmarshal(policyResp.NetworkSecurityPolicyJSON, policy)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
policy.Status = params.Status
|
||||
|
||||
err = policy.Init()
|
||||
if err != nil {
|
||||
this.Fail("配置校验失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
policyJSON, err := json.Marshal(policy)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().NodeClusterRPC().UpdateNodeClusterNetworkSecurityPolicy(this.AdminContext(), &pb.UpdateNodeClusterNetworkSecurityPolicyRequest{
|
||||
NodeClusterId: params.ClusterId,
|
||||
NetworkSecurityPolicyJSON: policyJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -44,17 +44,10 @@ func (this *ClusterHelper) filterMenuItems1(items []maps.Map, info *pb.FindEnabl
|
||||
|
||||
func (this *ClusterHelper) filterMenuItems2(items []maps.Map, info *pb.FindEnabledNodeClusterConfigInfoResponse, clusterIdString string, selectedItem string, actionPtr actions.ActionWrapper) []maps.Map {
|
||||
if teaconst.IsPlus {
|
||||
items = append(items, maps.Map{
|
||||
"name": this.Lang(actionPtr, codes.NodeClusterMenu_SettingSecurityPolicy),
|
||||
"url": "/clusters/cluster/settings/network-security?clusterId=" + clusterIdString,
|
||||
"isActive": selectedItem == "networkSecurity",
|
||||
"isOn": info != nil && info.HasNetworkSecurityPolicy, // TODO 将来 加入 info.HasDDoSProtection
|
||||
})
|
||||
|
||||
items = append(items, maps.Map{
|
||||
"name": "-",
|
||||
})
|
||||
if plusutils.CheckComponent(plusutils.ComponentCodeScheduling) {
|
||||
items = append(items, maps.Map{
|
||||
"name": "-",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": this.Lang(actionPtr, codes.NodeClusterMenu_SettingSchedule),
|
||||
"url": "/clusters/cluster/settings/schedule?clusterId=" + clusterIdString,
|
||||
@@ -89,14 +82,12 @@ func (this *ClusterHelper) filterMenuItems2(items []maps.Map, info *pb.FindEnabl
|
||||
"isOn": info != nil && info.HasSystemServices,
|
||||
})
|
||||
|
||||
{
|
||||
items = append(items, maps.Map{
|
||||
"name": this.Lang(actionPtr, codes.NodeClusterMenu_SettingTOA),
|
||||
"url": "/clusters/cluster/settings/toa?clusterId=" + clusterIdString,
|
||||
"isActive": selectedItem == "toa",
|
||||
"isOn": info != nil && info.IsTOAEnabled,
|
||||
})
|
||||
}
|
||||
items = append(items, maps.Map{
|
||||
"name": this.Lang(actionPtr, codes.NodeClusterMenu_SettingTOA),
|
||||
"url": "/clusters/cluster/settings/toa?clusterId=" + clusterIdString,
|
||||
"isActive": selectedItem == "toa",
|
||||
"isOn": info != nil && info.IsTOAEnabled,
|
||||
})
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user