diff --git a/backend/app/service/website.go b/backend/app/service/website.go index ee3fc49bf..c624c998f 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -9,6 +9,7 @@ import ( "encoding/pem" "errors" "fmt" + "github.com/1Panel-dev/1Panel/backend/utils/common" "os" "path" "reflect" @@ -454,6 +455,15 @@ func (w WebsiteService) CreateWebsiteDomain(create request.WebsiteDomainCreate) return domainModel, err } + if existDomains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithPort(create.Port)); len(existDomains) == 0 { + if existAppInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithPort(create.Port)); !reflect.DeepEqual(existAppInstall, model.AppInstall{}) { + return domainModel, buserr.WithMap(constant.ErrPortInOtherApp, map[string]interface{}{"port": create.Port, "apps": existAppInstall.App.Name}, nil) + } + if common.ScanPort(create.Port) { + return domainModel, buserr.WithDetail(constant.ErrPortInUsed, create.Port, nil) + } + } + website, err := websiteRepo.GetFirst(commonRepo.WithByID(create.WebsiteID)) if err != nil { return domainModel, err diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index bd402b9d1..754bac182 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -20,7 +20,7 @@ ErrPortInUsed: "{{ .detail }} port already in use" ErrAppLimit: "App exceeds install limit" ErrAppRequired: "{{ .detail }} app is required" ErrNotInstall: "App not installed" -ErrPortInOtherApp: "{{ .port }} port already in use by {{ .apps }}" +ErrPortInOtherApp: "{{ .port }} port already in use by app {{ .apps }}" ErrDbUserNotValid: "Stock database, username and password do not match!" ErrDockerComposeNotValid: "docker-compose file format error!" ErrUpdateBuWebsite: 'The application was updated successfully, but the modification of the website configuration file failed, please check the configuration!' diff --git a/backend/i18n/lang/zh-Hant.yaml b/backend/i18n/lang/zh-Hant.yaml index 9d32b42bf..74a1a9b85 100644 --- a/backend/i18n/lang/zh-Hant.yaml +++ b/backend/i18n/lang/zh-Hant.yaml @@ -20,7 +20,7 @@ ErrPortInUsed: "{{ .detail }} 端口已被佔用!" ErrAppLimit: "應用超出安裝數量限制" ErrAppRequired: "請先安裝 {{ .detail }} 應用" ErrNotInstall: "應用未安裝" -ErrPortInOtherApp: "{{ .port }} 端口已被 {{ .apps }}佔用!" +ErrPortInOtherApp: "{{ .port }} 端口已被應用 {{ .apps }} 佔用!" ErrDbUserNotValid: "儲存資料庫,用戶名密碼不匹配!" ErrDockerComposeNotValid: "docker-compose 文件格式錯誤" ErrUpdateBuWebsite: '應用更新成功,但是網站配置文件修改失敗,請檢查配置!' diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index 24488f31d..5146c27d0 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -20,7 +20,7 @@ ErrPortInUsed: "{{ .detail }} 端口已被占用!" ErrAppLimit: "应用超出安装数量限制" ErrAppRequired: "请先安装 {{ .detail }} 应用" ErrNotInstall: "应用未安装" -ErrPortInOtherApp: "{{ .port }} 端口已被 {{ .apps }}占用!" +ErrPortInOtherApp: "{{ .port }} 端口已被应用 {{ .apps }} 占用!" ErrDbUserNotValid: "存量数据库,用户名密码不匹配!" ErrDockerComposeNotValid: "docker-compose 文件格式错误" ErrUpdateBuWebsite: '应用更新成功,但是网站配置文件修改失败,请检查配置!'