集群可以设置默认的WAF策略、缓存策略

This commit is contained in:
刘祥超
2020-12-17 15:50:44 +08:00
parent 5c4d3c31f0
commit 65384082f7
100 changed files with 1172 additions and 488 deletions

View File

@@ -6,7 +6,6 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
"github.com/TeaOSLab/EdgeCommon/pkg/messageconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/lists"
)
// 通知使用此WAF策略的集群更新
@@ -15,18 +14,12 @@ func NotifyUpdateToClustersWithFirewallPolicyId(ctx context.Context, firewallPol
if err != nil {
return err
}
resp, err := client.ServerRPC().FindAllEnabledServersWithHTTPFirewallPolicyId(ctx, &pb.FindAllEnabledServersWithHTTPFirewallPolicyIdRequest{FirewallPolicyId: firewallPolicyId})
resp, err := client.NodeClusterRPC().FindAllEnabledNodeClustersWithHTTPFirewallPolicyId(ctx, &pb.FindAllEnabledNodeClustersWithHTTPFirewallPolicyIdRequest{HttpFirewallPolicyId: firewallPolicyId})
if err != nil {
return err
}
clusterIds := []int64{}
for _, server := range resp.Servers {
if !lists.ContainsInt64(clusterIds, server.Cluster.Id) {
clusterIds = append(clusterIds, server.Cluster.Id)
}
}
for _, clusterId := range clusterIds {
_, err = nodeutils.SendMessageToCluster(ctx, clusterId, messageconfigs.MessageCodeIPListChanged, &messageconfigs.IPListChangedMessage{}, 3)
for _, cluster := range resp.NodeClusters {
_, err = nodeutils.SendMessageToCluster(ctx, cluster.Id, messageconfigs.MessageCodeIPListChanged, &messageconfigs.IPListChangedMessage{}, 3)
if err != nil {
return err
}