From e43de9789098c83e00730a0d623a94a3574602a5 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Sun, 5 Nov 2023 21:39:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9B=E5=BB=BA=E7=BD=91=E7=AB=99-?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=9F=9F=E5=90=8D=E5=A2=9E=E5=8A=A0=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E6=A0=A1=E9=AA=8C=20(#2807)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/website_utils.go | 5 ++++- backend/i18n/lang/en.yaml | 2 ++ backend/i18n/lang/zh-Hant.yaml | 2 ++ backend/i18n/lang/zh.yaml | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/app/service/website_utils.go b/backend/app/service/website_utils.go index 8102f0c8f..94ce7724f 100644 --- a/backend/app/service/website_utils.go +++ b/backend/app/service/website_utils.go @@ -40,7 +40,10 @@ func getDomain(domainStr string, defaultPort int) (model.WebsiteDomain, error) { portStr := domainArray[1] portN, err := strconv.Atoi(portStr) if err != nil { - return model.WebsiteDomain{}, err + return model.WebsiteDomain{}, buserr.New("ErrTypePort") + } + if portN <= 0 || portN > 65535 { + return model.WebsiteDomain{}, buserr.New("ErrTypePortRange") } domain.Port = portN return domain, nil diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index b67865abd..6a4a7238a 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -18,6 +18,8 @@ ErrPortExist: '{{ .port }} port is already occupied by {{ .type }} [{{ .name }}] TYPE_APP: "Application" TYPE_RUNTIME: "Runtime environment" TYPE_DOMAIN: "Domain name" +ErrTypePort: 'Port {{name}} format error' +ErrTypePortRange: 'Port range needs to be between 1-65535' #app ErrPortInUsed: "{{ .detail }} port already in use" diff --git a/backend/i18n/lang/zh-Hant.yaml b/backend/i18n/lang/zh-Hant.yaml index 1921fd6e1..f5ec24e6c 100644 --- a/backend/i18n/lang/zh-Hant.yaml +++ b/backend/i18n/lang/zh-Hant.yaml @@ -18,6 +18,8 @@ ErrPortExist: '{{ .port }} 埠已被 {{ .type }} [{{ .name }}] 佔用' TYPE_APP: "應用" TYPE_RUNTIME: "運作環境" TYPE_DOMAIN: "網域名稱" +ErrTypePort: '埠 {{name}} 格式錯誤' +ErrTypePortRange: '連接埠範圍需要在 1-65535 之間' #app ErrPortInUsed: "{{ .detail }} 端口已被佔用!" diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index 64b67d515..1935d459c 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -18,6 +18,8 @@ ErrPortExist: '{{ .port }} 端口已被 {{ .type }} [{{ .name }}] 占用' TYPE_APP: "应用" TYPE_RUNTIME: "运行环境" TYPE_DOMAIN: "域名" +ErrTypePort: '端口 {{name}} 格式错误' +ErrTypePortRange: '端口范围需要在 1-65535 之间' #app ErrPortInUsed: "{{ .detail }} 端口已被占用!"