优化nftables相关代码

This commit is contained in:
刘祥超
2022-06-09 19:12:10 +08:00
parent 74f1bf330d
commit 885defbf31
4 changed files with 40 additions and 3 deletions

View File

@@ -23,12 +23,13 @@ func NewFirewalld() *Firewalld {
path, err := exec.LookPath("firewall-cmd")
if err == nil && len(path) > 0 {
var cmd = exec.Command(path, "-V")
var cmd = exec.Command(path, "--state")
err := cmd.Run()
if err == nil {
firewalld.exe = path
// TODO check firewalld status with 'firewall-cmd --state' (running or not running),
// but we should recover the state when firewalld state changes, maybe check it every minutes
firewalld.isReady = true
firewalld.init()
}