优化iptables+firewall-cmd找不到时的提示

This commit is contained in:
GoEdgeLab
2021-11-15 09:45:03 +08:00
parent 8855b3c173
commit ae2330a855
2 changed files with 12 additions and 0 deletions

View File

@@ -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
}
}