From 93b72ad45fd3a429d03755ad4e1d626fff461a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Fri, 27 Sep 2024 17:47:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E9=98=B2=E7=81=AB?= =?UTF-8?q?=E5=A2=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/firewall/firewall.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/firewall/firewall.go b/pkg/firewall/firewall.go index 9fb05caa..072079da 100644 --- a/pkg/firewall/firewall.go +++ b/pkg/firewall/firewall.go @@ -130,7 +130,9 @@ func (r *Firewall) Port(port FireInfo, operation string) error { if err != nil { return fmt.Errorf("%s port %d/%s failed, err: %s", operation, port.Port, port.Protocol, stdout) } - return systemctl.Reload("firewalld") + + _, err = shell.Execf("firewall-cmd --reload") + return err } func (r *Firewall) RichRules(rule FireInfo, operation string) error { @@ -156,7 +158,8 @@ func (r *Firewall) RichRules(rule FireInfo, operation string) error { } } - return systemctl.Reload("firewalld") + _, err := shell.Execf("firewall-cmd --reload") + return err } func (r *Firewall) PortForward(info Forward, operation string) error { @@ -178,7 +181,8 @@ func (r *Firewall) PortForward(info Forward, operation string) error { return fmt.Errorf("%s port forward failed, err: %s", operation, out) } - return systemctl.Reload("firewalld") + _, err = shell.Execf("firewall-cmd --reload") + return err } func (r *Firewall) parseRichRule(line string) (*FireInfo, error) { @@ -208,10 +212,11 @@ func (r *Firewall) enableForward() error { return fmt.Errorf("%s: %s", err, out) } - return systemctl.Reload("firewalld") + _, err = shell.Execf("firewall-cmd --reload") + return err } - return fmt.Errorf("%s: %s", err, out) + return fmt.Errorf("%v: %s", err, out) } return nil