MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / execDDoSProtectionChangedTask

Method execDDoSProtectionChangedTask

internal/nodes/node_tasks.go:179–210  ·  view source on GitHub ↗

DDoS配置变更

(rpcClient *rpc.RPCClient)

Source from the content-addressed store, hash-verified

177
178// DDoS配置变更
179func (this *Node) execDDoSProtectionChangedTask(rpcClient *rpc.RPCClient) error {
180 resp, err := rpcClient.NodeRPC.FindNodeDDoSProtection(rpcClient.Context(), &pb.FindNodeDDoSProtectionRequest{})
181 if err != nil {
182 return err
183 }
184 if len(resp.DdosProtectionJSON) == 0 {
185 if sharedNodeConfig != nil {
186 sharedNodeConfig.DDoSProtection = nil
187 }
188 return nil
189 }
190
191 var ddosProtectionConfig = &ddosconfigs.ProtectionConfig{}
192 err = json.Unmarshal(resp.DdosProtectionJSON, ddosProtectionConfig)
193 if err != nil {
194 return fmt.Errorf("decode DDoS protection config failed: %w", err)
195 }
196
197 if ddosProtectionConfig != nil && sharedNodeConfig != nil {
198 sharedNodeConfig.DDoSProtection = ddosProtectionConfig
199 }
200
201 go func() {
202 err = firewalls.SharedDDoSProtectionManager.Apply(ddosProtectionConfig)
203 if err != nil {
204 // 不阻塞
205 remotelogs.Warn("NODE", "apply DDoS protection failed: "+err.Error())
206 }
207 }()
208
209 return nil
210}
211
212// 服务全局配置变更
213func (this *Node) execGlobalServerConfigChangedTask(rpcClient *rpc.RPCClient) error {

Callers 1

execTaskMethod · 0.95

Calls 5

WarnFunction · 0.92
ContextMethod · 0.80
ErrorfMethod · 0.80
ApplyMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected