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:
parent
e43de97890
commit
9d1757dba6
@ -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 {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user