Browse Source

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

pull/873/head
ssongliu 2 years ago committed by GitHub
parent
commit
f4f83283d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      backend/app/service/container.go
  2. 2
      frontend/src/views/container/container/create/index.vue

11
backend/app/service/container.go

@ -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)
}

2
frontend/src/views/container/container/create/index.vue

@ -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>

Loading…
Cancel
Save