1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

feat: Node.js 运行环境外部映射端口增加校验 (#2808)

This commit is contained in:
zhengkunwang 2023-11-05 21:41:31 +08:00 committed by GitHub
parent e43de97890
commit 9d1757dba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -87,6 +87,11 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (err error) {
if err = checkPortExist(create.Port); err != nil {
return err
}
for _, export := range create.ExposedPorts {
if err = checkPortExist(export.HostPort); err != nil {
return err
}
}
if containerName, ok := create.Params["CONTAINER_NAME"]; ok {
if err := checkContainerName(containerName.(string)); err != nil {
return err
@ -342,6 +347,11 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
}
runtime.Port = req.Port
}
for _, export := range req.ExposedPorts {
if err = checkPortExist(export.HostPort); err != nil {
return err
}
}
if containerName, ok := req.Params["CONTAINER_NAME"]; ok {
envs, err := gotenv.Unmarshal(runtime.Env)
if err != nil {

View File

@ -256,7 +256,6 @@ const rules = ref<any>({
HOST_IP: [Rules.requiredSelect],
EXEC_SCRIPT: [Rules.requiredSelect],
CONTAINER_NAME: [Rules.requiredInput, Rules.containerName],
CUSTOM_SCRIPT: [Rules.requiredInput],
},
});
const scripts = ref<Runtime.NodeScripts[]>([]);
@ -456,7 +455,8 @@ const getRuntime = async (id: number) => {
runtime.exposedPorts = data.exposedPorts || [];
editParams.value = data.appParams;
searchApp(data.appID);
if (data.params['CUSTOM_SCRIPT'] == '0') {
if (data.params['CUSTOM_SCRIPT'] == undefined || data.params['CUSTOM_SCRIPT'] == '0') {
data.params['CUSTOM_SCRIPT'] = '0';
getScripts();
}
open.value = true;