fix: 容器创建端口校验修改 (#872)

This commit is contained in:
ssongliu 2023-05-05 11:17:28 +08:00 committed by GitHub
parent aed4a55655
commit f4f83283d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -418,8 +418,8 @@ func checkPortStats(ports []dto.PortHelper) (nat.PortMap, error) {
return portMap, nil
}
for _, port := range ports {
if strings.Contains(port.HostPort, "-") {
if !strings.Contains(port.ContainerPort, "-") {
if strings.Contains(port.ContainerPort, "-") {
if !strings.Contains(port.HostPort, "-") {
return portMap, buserr.New(constant.ErrPortRules)
}
hostStart, _ := strconv.Atoi(strings.Split(port.HostPort, "-")[0])
@ -442,7 +442,12 @@ func checkPortStats(ports []dto.PortHelper) (nat.PortMap, error) {
}
}
} else {
portItem, _ := strconv.Atoi(port.HostPort)
portItem := 0
if strings.Contains(port.HostPort, "-") {
portItem, _ = strconv.Atoi(strings.Split(port.HostPort, "-")[0])
} else {
portItem, _ = strconv.Atoi(port.HostPort)
}
if common.ScanPort(portItem) {
return portMap, buserr.WithDetail(constant.ErrPortInUsed, portItem, nil)
}

View File

@ -58,7 +58,7 @@
<td width="20%">
<el-select v-model="row.protocol" style="width: 100%">
<el-option label="tcp" value="tcp" />
<el-option label="upd" value="upd" />
<el-option label="udp" value="udp" />
</el-select>
</td>
<td>