From 408357dfcff6afaa4ef762393eaf56f101550d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Tue, 1 Nov 2022 17:37:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96DDoS=E9=98=B2=E6=8A=A4?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/firewalls/ddos_protection.go | 3 +++ internal/nodes/api_stream.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/firewalls/ddos_protection.go b/internal/firewalls/ddos_protection.go index 54b904f..118c3fa 100644 --- a/internal/firewalls/ddos_protection.go +++ b/internal/firewalls/ddos_protection.go @@ -91,6 +91,9 @@ func (this *DDoSProtectionManager) Apply(config *ddosconfigs.ProtectionConfig) e } if nftablesInstance == nil { + if config == nil || !config.IsOn() { + return nil + } return errors.New("nftables instance should not be nil") } diff --git a/internal/nodes/api_stream.go b/internal/nodes/api_stream.go index 57db159..8fa45c7 100644 --- a/internal/nodes/api_stream.go +++ b/internal/nodes/api_stream.go @@ -407,7 +407,7 @@ func (this *APIStream) handleCheckLocalFirewall(message *pb.NodeStreamMessage) e 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()) + this.replyFail(message.RequestId, dataMessage.Name+" was installed, but apply DDoS protection config failed: "+err.Error()) } else { this.replyOk(message.RequestId, string(result.AsJSON())) }