@@ -542,16 +542,18 @@ func (s *CliService) Port(ctx context.Context, cmd *cli.Command) error {
542542 }
543543
544544 // 放行端口
545- fw := firewall .NewFirewall ()
546- err = fw .Port (firewall.FireInfo {
547- Type : firewall .TypeNormal ,
548- PortStart : config .HTTP .Port ,
549- PortEnd : config .HTTP .Port ,
550- Direction : firewall .DirectionIn ,
551- Strategy : firewall .StrategyAccept ,
552- }, firewall .OperationAdd )
553- if err != nil {
554- return err
545+ if ok , _ := systemctl .IsEnabled ("firewalld" ); ok {
546+ fw := firewall .NewFirewall ()
547+ err = fw .Port (firewall.FireInfo {
548+ Type : firewall .TypeNormal ,
549+ PortStart : port ,
550+ PortEnd : port ,
551+ Direction : firewall .DirectionIn ,
552+ Strategy : firewall .StrategyAccept ,
553+ }, firewall .OperationAdd )
554+ if err != nil {
555+ return err
556+ }
555557 }
556558
557559 if err = io .Write ("/usr/local/etc/panel/config.yml" , string (encoded ), 0700 ); err != nil {
@@ -990,8 +992,8 @@ checkPort:
990992 fw := firewall .NewFirewall ()
991993 _ = fw .Port (firewall.FireInfo {
992994 Type : firewall .TypeNormal ,
993- PortStart : config . HTTP . Port ,
994- PortEnd : config . HTTP . Port ,
995+ PortStart : port ,
996+ PortEnd : port ,
995997 Direction : firewall .DirectionIn ,
996998 Strategy : firewall .StrategyAccept ,
997999 }, firewall .OperationAdd )
0 commit comments