From 5606d980be760140e2f9a1298fcaa1c4a1846aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Mon, 11 Nov 2024 14:13:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20cli=E4=B8=8B=E4=BF=AE=E6=94=B9=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E5=90=8E=E8=87=AA=E5=8A=A8=E6=94=BE=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/cli.go | 14 ++++++++++++++ pkg/db/redis.go | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/service/cli.go b/internal/service/cli.go index 94968726..bbf052bf 100644 --- a/internal/service/cli.go +++ b/internal/service/cli.go @@ -21,6 +21,7 @@ import ( "github.com/TheTNB/panel/internal/http/request" "github.com/TheTNB/panel/pkg/api" "github.com/TheTNB/panel/pkg/cert" + "github.com/TheTNB/panel/pkg/firewall" "github.com/TheTNB/panel/pkg/io" "github.com/TheTNB/panel/pkg/ntp" "github.com/TheTNB/panel/pkg/systemctl" @@ -390,6 +391,19 @@ func (s *CliService) Port(ctx context.Context, cmd *cli.Command) error { return err } + // 放行端口 + fw := firewall.NewFirewall() + err = fw.Port(firewall.FireInfo{ + Type: firewall.TypeNormal, + PortStart: uint(config.HTTP.Port), + PortEnd: uint(config.HTTP.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 { return err } diff --git a/pkg/db/redis.go b/pkg/db/redis.go index 832030b0..5e8e6fd4 100644 --- a/pkg/db/redis.go +++ b/pkg/db/redis.go @@ -151,7 +151,7 @@ func (r *Redis) Data(page, pageSize int) ([]RedisKV, error) { continue } if kv.Length > 500 { - value = fmt.Sprintf("data is too long, can't display") + value = "data is too long, can't display" } if str, ok := value.(string); ok {