From 5acf1e6eb76820ff04f8af68e8144e14cfbbaf60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Wed, 16 Oct 2024 15:22:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=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/data/setting.go | 11 +++++++++++ internal/http/rule/exists.go | 2 +- internal/http/rule/not_exists.go | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/internal/data/setting.go b/internal/data/setting.go index aa550acc..872169b4 100644 --- a/internal/data/setting.go +++ b/internal/data/setting.go @@ -16,6 +16,7 @@ import ( "github.com/TheTNB/panel/internal/app" "github.com/TheTNB/panel/internal/biz" "github.com/TheTNB/panel/internal/http/request" + "github.com/TheTNB/panel/pkg/firewall" "github.com/TheTNB/panel/pkg/io" "github.com/TheTNB/panel/pkg/shell" "github.com/TheTNB/panel/pkg/tools" @@ -201,6 +202,16 @@ func (r *settingRepo) UpdatePanelSetting(ctx context.Context, setting *request.P config.HTTP.Entrance = setting.Entrance config.HTTP.TLS = setting.HTTPS + // 放行端口 + fw := firewall.NewFirewall() + err = fw.Port(firewall.FireInfo{ + Port: uint(config.HTTP.Port), + Protocol: "tcp", + }, firewall.OperationAdd) + if err != nil { + return false, err + } + encoded, err := yaml.MarshalWithOptions(config, yaml.WithComment(cm)) if err != nil { return false, err diff --git a/internal/http/rule/exists.go b/internal/http/rule/exists.go index f43b4e66..b5d480ce 100644 --- a/internal/http/rule/exists.go +++ b/internal/http/rule/exists.go @@ -16,7 +16,7 @@ func NewExists(db *gorm.DB) *Exists { return &Exists{DB: db} } -// Exists 格式 `exists=categories,id,other_field` +// Exists 格式 `exists=categories id other_field` func (r *Exists) Exists(fl validator.FieldLevel) bool { requestValue := fl.Field().Interface() params := strings.Fields(fl.Param()) diff --git a/internal/http/rule/not_exists.go b/internal/http/rule/not_exists.go index f86ebe99..b5919c4c 100644 --- a/internal/http/rule/not_exists.go +++ b/internal/http/rule/not_exists.go @@ -16,7 +16,7 @@ func NewNotExists(db *gorm.DB) *NotExists { return &NotExists{DB: db} } -// NotExists 格式 `not_exists=categories,id,other_field` +// NotExists 格式 `not_exists=categories id other_field` func (r *NotExists) NotExists(fl validator.FieldLevel) bool { requestValue := fl.Field().Interface() params := strings.Fields(fl.Param())