From 0d5540295f710fa8f03fad7ce8ef4bd87128c3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Tue, 21 Jun 2022 10:02:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DDDoS=E9=98=B2=E6=8A=A4?= =?UTF-8?q?=E8=A7=84=E5=88=99=E6=97=A0=E6=B3=95=E7=94=9F=E6=88=90=E7=9A=84?= =?UTF-8?q?Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/firewalls/ddos_protection.go | 4 ++-- internal/nodes/api_stream.go | 2 +- internal/nodes/node.go | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/firewalls/ddos_protection.go b/internal/firewalls/ddos_protection.go index 8486fd9..6294423 100644 --- a/internal/firewalls/ddos_protection.go +++ b/internal/firewalls/ddos_protection.go @@ -33,7 +33,7 @@ func init() { nodeConfig, _ := nodeconfigs.SharedNodeConfig() if nodeConfig != nil { - err := SharedDDoSProtectionManager.Apply(nodeConfig.DDOSProtection) + err := SharedDDoSProtectionManager.Apply(nodeConfig.DDoSProtection) if err != nil { remotelogs.Error("FIREWALL", "apply DDoS protection failed: "+err.Error()) } @@ -43,7 +43,7 @@ func init() { events.On(events.EventNFTablesReady, func() { nodeConfig, _ := nodeconfigs.SharedNodeConfig() if nodeConfig != nil { - err := SharedDDoSProtectionManager.Apply(nodeConfig.DDOSProtection) + err := SharedDDoSProtectionManager.Apply(nodeConfig.DDoSProtection) if err != nil { remotelogs.Error("FIREWALL", "apply DDoS protection failed: "+err.Error()) } diff --git a/internal/nodes/api_stream.go b/internal/nodes/api_stream.go index bee2b67..9fdf33a 100644 --- a/internal/nodes/api_stream.go +++ b/internal/nodes/api_stream.go @@ -406,7 +406,7 @@ func (this *APIStream) handleCheckLocalFirewall(message *pb.NodeStreamMessage) e "version": version, } - var protectionConfig = sharedNodeConfig.DDOSProtection + var protectionConfig = sharedNodeConfig.DDoSProtection err = firewalls.SharedDDoSProtectionManager.Apply(protectionConfig) if err != nil { this.replyFail(message.RequestId, dataMessage.Name+"was installed, but apply DDoS protection config failed: "+err.Error()) diff --git a/internal/nodes/node.go b/internal/nodes/node.go index de1fe89..9566ccf 100644 --- a/internal/nodes/node.go +++ b/internal/nodes/node.go @@ -386,7 +386,7 @@ func (this *Node) loop() error { } if len(resp.DdosProtectionJSON) == 0 { if sharedNodeConfig != nil { - sharedNodeConfig.DDOSProtection = nil + sharedNodeConfig.DDoSProtection = nil } } else { var ddosProtectionConfig = &ddosconfigs.ProtectionConfig{} @@ -395,6 +395,10 @@ func (this *Node) loop() error { return errors.New("decode DDoS protection config failed: " + err.Error()) } + if sharedNodeConfig != nil { + sharedNodeConfig.DDoSProtection = ddosProtectionConfig + } + err = firewalls.SharedDDoSProtectionManager.Apply(ddosProtectionConfig) if err != nil { // 不阻塞