mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-28 16:36:36 +08:00
实现集群CC防护策略设置
This commit is contained in:
@@ -80,6 +80,8 @@ func (this *Node) execTask(rpcClient *rpc.RPCClient, task *pb.NodeTask) error {
|
||||
err = this.execUserServersStateChangedTask(rpcClient, task)
|
||||
case "uamPolicyChanged":
|
||||
err = this.execUAMPolicyChangedTask(rpcClient)
|
||||
case "httpCCPolicyChanged":
|
||||
err = this.execHTTPCCPolicyChangedTask(rpcClient)
|
||||
case "httpPagesPolicyChanged":
|
||||
err = this.execHTTPPagesPolicyChangedTask(rpcClient)
|
||||
case "updatingServers":
|
||||
@@ -189,6 +191,34 @@ func (this *Node) execUAMPolicyChangedTask(rpcClient *rpc.RPCClient) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// HTTP CC策略变更
|
||||
func (this *Node) execHTTPCCPolicyChangedTask(rpcClient *rpc.RPCClient) error {
|
||||
remotelogs.Println("NODE", "updating http cc policies ...")
|
||||
resp, err := rpcClient.NodeRPC.FindNodeHTTPCCPolicies(rpcClient.Context(), &pb.FindNodeHTTPCCPoliciesRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var httpCCPolicyMap = map[int64]*nodeconfigs.HTTPCCPolicy{}
|
||||
for _, policy := range resp.HttpCCPolicies {
|
||||
if len(policy.HttpCCPolicyJSON) > 0 {
|
||||
var httpCCPolicy = nodeconfigs.NewHTTPCCPolicy()
|
||||
err = json.Unmarshal(policy.HttpCCPolicyJSON, httpCCPolicy)
|
||||
if err != nil {
|
||||
remotelogs.Error("NODE", "decode http cc policy failed: "+err.Error())
|
||||
continue
|
||||
}
|
||||
err = httpCCPolicy.Init()
|
||||
if err != nil {
|
||||
remotelogs.Error("NODE", "initialize http cc policy failed: "+err.Error())
|
||||
continue
|
||||
}
|
||||
httpCCPolicyMap[policy.NodeClusterId] = httpCCPolicy
|
||||
}
|
||||
}
|
||||
sharedNodeConfig.UpdateHTTPCCPolicies(httpCCPolicyMap)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 自定义页面策略变更
|
||||
func (this *Node) execHTTPPagesPolicyChangedTask(rpcClient *rpc.RPCClient) error {
|
||||
remotelogs.Println("NODE", "updating http pages policies ...")
|
||||
|
||||
Reference in New Issue
Block a user