From 5576426f3382756764b7c851af16c77b37f281b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Sat, 23 Aug 2025 15:34:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=98=B2=E7=81=AB?= =?UTF-8?q?=E5=A2=99=E7=AB=AF=E5=8F=A3=E6=94=BE=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/data/setting.go | 4 ++-- internal/service/cli.go | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/internal/data/setting.go b/internal/data/setting.go index 837da02e..ae2b383c 100644 --- a/internal/data/setting.go +++ b/internal/data/setting.go @@ -316,8 +316,8 @@ func (r *settingRepo) UpdatePanel(req *request.SettingPanel) (bool, error) { fw := firewall.NewFirewall() err = fw.Port(firewall.FireInfo{ Type: firewall.TypeNormal, - PortStart: config.HTTP.Port, - PortEnd: config.HTTP.Port, + PortStart: req.Port, + PortEnd: req.Port, Direction: firewall.DirectionIn, Strategy: firewall.StrategyAccept, }, firewall.OperationAdd) diff --git a/internal/service/cli.go b/internal/service/cli.go index bf883c83..2276f087 100644 --- a/internal/service/cli.go +++ b/internal/service/cli.go @@ -542,16 +542,18 @@ func (s *CliService) Port(ctx context.Context, cmd *cli.Command) error { } // 放行端口 - fw := firewall.NewFirewall() - err = fw.Port(firewall.FireInfo{ - Type: firewall.TypeNormal, - PortStart: config.HTTP.Port, - PortEnd: config.HTTP.Port, - Direction: firewall.DirectionIn, - Strategy: firewall.StrategyAccept, - }, firewall.OperationAdd) - if err != nil { - return err + if ok, _ := systemctl.IsEnabled("firewalld"); ok { + fw := firewall.NewFirewall() + err = fw.Port(firewall.FireInfo{ + Type: firewall.TypeNormal, + PortStart: port, + PortEnd: port, + Direction: firewall.DirectionIn, + Strategy: firewall.StrategyAccept, + }, firewall.OperationAdd) + if err != nil { + return err + } } if err = io.Write("/usr/local/etc/panel/config.yml", string(encoded), 0700); err != nil { @@ -990,8 +992,8 @@ checkPort: fw := firewall.NewFirewall() _ = fw.Port(firewall.FireInfo{ Type: firewall.TypeNormal, - PortStart: config.HTTP.Port, - PortEnd: config.HTTP.Port, + PortStart: port, + PortEnd: port, Direction: firewall.DirectionIn, Strategy: firewall.StrategyAccept, }, firewall.OperationAdd)