mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-17 21:08:25 +08:00
feat: Node.js 运行环境外部映射端口增加校验 (#2808)
This commit is contained in:
parent
e43de97890
commit
9d1757dba6
2 changed files with 12 additions and 2 deletions
|
|
@ -87,6 +87,11 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (err error) {
|
||||||
if err = checkPortExist(create.Port); err != nil {
|
if err = checkPortExist(create.Port); err != nil {
|
||||||
return err
|
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 containerName, ok := create.Params["CONTAINER_NAME"]; ok {
|
||||||
if err := checkContainerName(containerName.(string)); err != nil {
|
if err := checkContainerName(containerName.(string)); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -342,6 +347,11 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
|
||||||
}
|
}
|
||||||
runtime.Port = req.Port
|
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 {
|
if containerName, ok := req.Params["CONTAINER_NAME"]; ok {
|
||||||
envs, err := gotenv.Unmarshal(runtime.Env)
|
envs, err := gotenv.Unmarshal(runtime.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,6 @@ const rules = ref<any>({
|
||||||
HOST_IP: [Rules.requiredSelect],
|
HOST_IP: [Rules.requiredSelect],
|
||||||
EXEC_SCRIPT: [Rules.requiredSelect],
|
EXEC_SCRIPT: [Rules.requiredSelect],
|
||||||
CONTAINER_NAME: [Rules.requiredInput, Rules.containerName],
|
CONTAINER_NAME: [Rules.requiredInput, Rules.containerName],
|
||||||
CUSTOM_SCRIPT: [Rules.requiredInput],
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const scripts = ref<Runtime.NodeScripts[]>([]);
|
const scripts = ref<Runtime.NodeScripts[]>([]);
|
||||||
|
|
@ -456,7 +455,8 @@ const getRuntime = async (id: number) => {
|
||||||
runtime.exposedPorts = data.exposedPorts || [];
|
runtime.exposedPorts = data.exposedPorts || [];
|
||||||
editParams.value = data.appParams;
|
editParams.value = data.appParams;
|
||||||
searchApp(data.appID);
|
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();
|
getScripts();
|
||||||
}
|
}
|
||||||
open.value = true;
|
open.value = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue