mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-29 10:16:09 +08:00
fix: add port check for php runtime port config (#8941)
This commit is contained in:
parent
721e370ad3
commit
8acf8b0b96
10 changed files with 30 additions and 4 deletions
|
|
@ -64,8 +64,13 @@ func (r *RuntimeRepo) WithNotId(id uint) DBOption {
|
|||
func (r *RuntimeRepo) WithPort(port int) DBOption {
|
||||
return func(g *gorm.DB) *gorm.DB {
|
||||
portStr := fmt.Sprintf("%d", port)
|
||||
regexPattern := fmt.Sprintf("(^|,)%s(,|$)", portStr)
|
||||
return g.Where("port REGEXP ?", regexPattern)
|
||||
return g.Debug().Where(
|
||||
"port = ? OR port LIKE ? OR port LIKE ? OR port LIKE ?",
|
||||
portStr,
|
||||
portStr+",%",
|
||||
"%,"+portStr,
|
||||
"%,"+portStr+",%",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1022,11 +1022,15 @@ func (r *RuntimeService) UpdatePHPContainer(req request.PHPContainerConfig) erro
|
|||
return err
|
||||
}
|
||||
var (
|
||||
hostPorts []string
|
||||
composeContent []byte
|
||||
)
|
||||
for _, export := range req.ExposedPorts {
|
||||
hostPorts = append(hostPorts, strconv.Itoa(export.HostPort))
|
||||
if strconv.Itoa(export.HostPort) == runtime.Port {
|
||||
return buserr.WithName("ErrPHPRuntimePortFailed", strconv.Itoa(export.HostPort))
|
||||
}
|
||||
if export.ContainerPort == 9000 {
|
||||
return buserr.New("ErrPHPPortIsDefault")
|
||||
}
|
||||
if err = checkRuntimePortExist(export.HostPort, false, runtime.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1075,6 +1079,7 @@ func (r *RuntimeService) UpdatePHPContainer(req request.PHPContainerConfig) erro
|
|||
for k, v := range newMap {
|
||||
envs[k] = v
|
||||
}
|
||||
envs["PANEL_APP_PORT_HTTP"] = runtime.Port
|
||||
envStr, err := gotenv.Marshal(envs)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -183,6 +183,8 @@ ErrScriptsNotFound: 'The scripts configuration item was not found in package.jso
|
|||
ErrContainerNameNotFound: 'Unable to get container name, please check .env file'
|
||||
ErrNodeModulesNotFound: 'The node_modules folder does not exist! Please edit the runtime environment or wait for the runtime environment to start successfully'
|
||||
ErrContainerNameIsNull: 'Container name does not exist'
|
||||
ErrPHPPortIsDefault: "Port 9000 is the default port, please modify and try again"
|
||||
ErrPHPRuntimePortFailed: "The port {{ .name }} is already used by the current runtime environment, please modify and try again"
|
||||
|
||||
#tool
|
||||
ErrConfigNotFound: 'Configuration file does not exist'
|
||||
|
|
|
|||
|
|
@ -183,6 +183,8 @@ ErrScriptsNotFound: 'スクリプト構成項目が package.json に見つかり
|
|||
ErrContainerNameNotFound: 'コンテナ名を取得できません。.env ファイルを確認してください'
|
||||
ErrNodeModulesNotFound: 'node_modules フォルダが存在しません。ランタイム環境を編集するか、ランタイム環境が正常に起動するまでお待ちください。'
|
||||
ErrContainerNameIsNull: 'コンテナ名が存在しません'
|
||||
ErrPHPPortIsDefault: "ポート9000はデフォルトポートです。修正してから再試行してください"
|
||||
ErrPHPRuntimePortFailed: "ポート {{ .name }} は現在のランタイム環境で使用されています。修正してから再試行してください"
|
||||
|
||||
#tool
|
||||
ErrConfigNotFound: '構成ファイルが存在しません'
|
||||
|
|
|
|||
|
|
@ -183,6 +183,8 @@ ErrScriptsNotFound: 'package.json에서 스크립트 구성 항목을 찾을 수
|
|||
ErrContainerNameNotFound: '컨테이너 이름을 가져올 수 없습니다. .env 파일을 확인하세요.'
|
||||
ErrNodeModulesNotFound: 'node_modules 폴더가 없습니다! 런타임 환경을 편집하거나 런타임 환경이 성공적으로 시작될 때까지 기다리십시오'
|
||||
ErrContainerNameIsNull: '컨테이너 이름이 존재하지 않습니다'
|
||||
ErrPHPPortIsDefault: "9000 포트는 기본 포트입니다. 수정 후 다시 시도하세요"
|
||||
ErrPHPRuntimePortFailed: "포트 {{ .name }} 는 현재 런타임 환경에서 이미 사용 중입니다. 수정 후 다시 시도하세요"
|
||||
|
||||
#도구
|
||||
ErrConfigNotFound: '구성 파일이 존재하지 않습니다'
|
||||
|
|
|
|||
|
|
@ -183,6 +183,8 @@ ErrScriptsNotFound: 'Item konfigurasi skrip tidak ditemui dalam package.json'
|
|||
ErrContainerNameNotFound: 'Tidak dapat mendapatkan nama kontena, sila semak fail .env'
|
||||
ErrNodeModulesNotFound: 'Folder node_modules tidak wujud! Sila edit persekitaran masa jalan atau tunggu persekitaran masa jalan berjaya dimulakan'
|
||||
ErrContainerNameIsNull: 'Nama kontena tidak wujud'
|
||||
ErrPHPPortIsDefault: "Порт 9000 является портом по умолчанию, пожалуйста, измените и попробуйте снова"
|
||||
ErrPHPRuntimePortFailed: "Порт {{ .name }} уже используется текущей средой выполнения, пожалуйста, измените и попробуйте снова"
|
||||
|
||||
#alat
|
||||
ErrConfigNotFound: 'Fail konfigurasi tidak wujud'
|
||||
|
|
|
|||
|
|
@ -183,6 +183,8 @@ ErrScriptsNotFound: 'O item de configuração de scripts não foi encontrado em
|
|||
ErrContainerNameNotFound: 'Não foi possível obter o nome do contêiner, verifique o arquivo .env'
|
||||
ErrNodeModulesNotFound: 'A pasta node_modules não existe! Edite o ambiente de execução ou aguarde até que o ambiente de execução inicie com sucesso'
|
||||
ErrContainerNameIsNull: 'O nome do contêiner não existe'
|
||||
ErrPHPPortIsDefault: "Port 9000 adalah port lalai, sila ubah dan cuba lagi"
|
||||
ErrPHPRuntimePortFailed: "Port {{ .name }} telah digunakan oleh persekitaran runtime semasa, sila ubah dan cuba lagi"
|
||||
|
||||
#ferramenta
|
||||
ErrConfigNotFound: 'O arquivo de configuração não existe'
|
||||
|
|
|
|||
|
|
@ -183,6 +183,8 @@ ErrScriptsNotFound: 'Элемент конфигурации скриптов н
|
|||
ErrContainerNameNotFound: 'Не удалось получить имя контейнера, проверьте файл .env'
|
||||
ErrNodeModulesNotFound: 'Папка node_modules не существует! Измените среду выполнения или дождитесь ее успешного запуска'
|
||||
ErrContainerNameIsNull: 'Имя контейнера не существует'
|
||||
ErrPHPPortIsDefault: "A porta 9000 é a porta padrão, por favor, modifique e tente novamente"
|
||||
ErrPHPRuntimePortFailed: "A porta {{ .name }} já está sendo usada pelo ambiente de tempo de execução atual, por favor, modifique e tente novamente"
|
||||
|
||||
#инструмент
|
||||
ErrConfigNotFound: 'Файл конфигурации не существует'
|
||||
|
|
|
|||
|
|
@ -183,6 +183,8 @@ ErrScriptsNotFound: '沒有在package.json 中找到scripts 設定項'
|
|||
ErrContainerNameNotFound: '無法取得容器名稱,請檢查.env 檔案'
|
||||
ErrNodeModulesNotFound: 'node_modules 資料夾不存在!請編輯運行環境或等待運行環境啟動成功'
|
||||
ErrContainerNameIsNull: '容器名稱不存在'
|
||||
ErrPHPPortIsDefault: "9000 端口為默認端口,請修改後重試"
|
||||
ErrPHPRuntimePortFailed: "{{ .name }} 端口已被當前運行環境使用,請修改後重試"
|
||||
|
||||
#tool
|
||||
ErrConfigNotFound: '設定檔不存在'
|
||||
|
|
|
|||
|
|
@ -182,6 +182,8 @@ ErrScriptsNotFound: "没有在 package.json 中找到 scripts 配置项"
|
|||
ErrContainerNameNotFound: "无法获取容器名称,请检查 .env 文件"
|
||||
ErrNodeModulesNotFound: "node_modules 文件夹不存在!请编辑运行环境或者等待运行环境启动成功"
|
||||
ErrContainerNameIsNull: "容器名称不存在"
|
||||
ErrPHPPortIsDefault: "9000 端口为默认端口,请修改后重试"
|
||||
ErrPHPRuntimePortFailed: "{{ .name }} 端口已被当前运行环境使用,请修改后重试"
|
||||
|
||||
#tool
|
||||
ErrConfigNotFound: "配置文件不存在"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue