From 565fd1c60585aa15d996a6c60998fad26f193f48 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Thu, 20 Apr 2023 18:51:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20ufw=20=E5=A2=9E=E5=8A=A0=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/utils/firewall/client/ufw.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/utils/firewall/client/ufw.go b/backend/utils/firewall/client/ufw.go index fd3e184b3..dd431300b 100644 --- a/backend/utils/firewall/client/ufw.go +++ b/backend/utils/firewall/client/ufw.go @@ -26,18 +26,19 @@ func (f *Ufw) Name() string { } func (f *Ufw) Status() (string, error) { - stdout, err := cmd.Execf("%s status | grep Status", f.CmdStr) - if err != nil { - return "", fmt.Errorf("load the firewall status failed, err: %s", stdout) - } + stdout, _ := cmd.Execf("%s status | grep Status", f.CmdStr) if stdout == "Status: active\n" { return "running", nil } + stdout1, _ := cmd.Execf("%s status | grep 状态", f.CmdStr) + if stdout1 == "状态: 激活\n" { + return "running", nil + } return "not running", nil } func (f *Ufw) Version() (string, error) { - stdout, err := cmd.Execf("%s version | grep ufw", f.CmdStr) + stdout, err := cmd.Execf("%s version | grep ufwHasNoPasswordSudo", f.CmdStr) if err != nil { return "", fmt.Errorf("load the firewall status failed, err: %s", stdout) }