mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
fix: 容器创建端口校验修改 (#872)
This commit is contained in:
parent
aed4a55655
commit
f4f83283d3
@ -418,8 +418,8 @@ func checkPortStats(ports []dto.PortHelper) (nat.PortMap, error) {
|
|||||||
return portMap, nil
|
return portMap, nil
|
||||||
}
|
}
|
||||||
for _, port := range ports {
|
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)
|
return portMap, buserr.New(constant.ErrPortRules)
|
||||||
}
|
}
|
||||||
hostStart, _ := strconv.Atoi(strings.Split(port.HostPort, "-")[0])
|
hostStart, _ := strconv.Atoi(strings.Split(port.HostPort, "-")[0])
|
||||||
@ -442,7 +442,12 @@ func checkPortStats(ports []dto.PortHelper) (nat.PortMap, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if common.ScanPort(portItem) {
|
||||||
return portMap, buserr.WithDetail(constant.ErrPortInUsed, portItem, nil)
|
return portMap, buserr.WithDetail(constant.ErrPortInUsed, portItem, nil)
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
<td width="20%">
|
<td width="20%">
|
||||||
<el-select v-model="row.protocol" style="width: 100%">
|
<el-select v-model="row.protocol" style="width: 100%">
|
||||||
<el-option label="tcp" value="tcp" />
|
<el-option label="tcp" value="tcp" />
|
||||||
<el-option label="upd" value="upd" />
|
<el-option label="udp" value="udp" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user