From 5a6ead1dd73e8b4821b472fece622b4f0a4a937f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 15 Nov 2021 09:45:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96iptables+firewall-cmd?= =?UTF-8?q?=E6=89=BE=E4=B8=8D=E5=88=B0=E6=97=B6=E7=9A=84=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/iplibrary/action_firewalld.go | 6 ++++++ internal/iplibrary/action_iptables.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/internal/iplibrary/action_firewalld.go b/internal/iplibrary/action_firewalld.go index c57148d..4c97b71 100644 --- a/internal/iplibrary/action_firewalld.go +++ b/internal/iplibrary/action_firewalld.go @@ -20,6 +20,8 @@ type FirewalldAction struct { BaseAction config *firewallconfigs.FirewallActionFirewalldConfig + + firewalldNotFound bool } func NewFirewalldAction() *FirewalldAction { @@ -82,6 +84,10 @@ func (this *FirewalldAction) runActionSingleIP(action string, listType IPListTyp if len(path) == 0 { path, err = exec.LookPath("firewall-cmd") if err != nil { + if this.firewalldNotFound { + return nil + } + this.firewalldNotFound = true return err } } diff --git a/internal/iplibrary/action_iptables.go b/internal/iplibrary/action_iptables.go index 2ac2f4b..37e0ced 100644 --- a/internal/iplibrary/action_iptables.go +++ b/internal/iplibrary/action_iptables.go @@ -19,6 +19,8 @@ type IPTablesAction struct { BaseAction config *firewallconfigs.FirewallActionIPTablesConfig + + iptablesNotFound bool } func NewIPTablesAction() *IPTablesAction { @@ -77,6 +79,10 @@ func (this *IPTablesAction) runActionSingleIP(action string, listType IPListType if len(path) == 0 { path, err = exec.LookPath("iptables") if err != nil { + if this.iptablesNotFound { + return nil + } + this.iptablesNotFound = true return err } }