mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-11 13:53:34 +08:00
优化iptables+firewall-cmd找不到时的提示
This commit is contained in:
@@ -20,6 +20,8 @@ type FirewalldAction struct {
|
|||||||
BaseAction
|
BaseAction
|
||||||
|
|
||||||
config *firewallconfigs.FirewallActionFirewalldConfig
|
config *firewallconfigs.FirewallActionFirewalldConfig
|
||||||
|
|
||||||
|
firewalldNotFound bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFirewalldAction() *FirewalldAction {
|
func NewFirewalldAction() *FirewalldAction {
|
||||||
@@ -82,6 +84,10 @@ func (this *FirewalldAction) runActionSingleIP(action string, listType IPListTyp
|
|||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
path, err = exec.LookPath("firewall-cmd")
|
path, err = exec.LookPath("firewall-cmd")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if this.firewalldNotFound {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
this.firewalldNotFound = true
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ type IPTablesAction struct {
|
|||||||
BaseAction
|
BaseAction
|
||||||
|
|
||||||
config *firewallconfigs.FirewallActionIPTablesConfig
|
config *firewallconfigs.FirewallActionIPTablesConfig
|
||||||
|
|
||||||
|
iptablesNotFound bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIPTablesAction() *IPTablesAction {
|
func NewIPTablesAction() *IPTablesAction {
|
||||||
@@ -77,6 +79,10 @@ func (this *IPTablesAction) runActionSingleIP(action string, listType IPListType
|
|||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
path, err = exec.LookPath("iptables")
|
path, err = exec.LookPath("iptables")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if this.iptablesNotFound {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
this.iptablesNotFound = true
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user