From 88814e3d74de3c92d0e243cbb9a184a6e0eda466 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:06:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=B9=E5=99=A8=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E5=B1=95=E7=A4=BA=E4=BC=98=E5=8C=96=20(#3263?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/container.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/app/service/container.go b/backend/app/service/container.go index 2ccf5707b..4e583bf9e 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -159,7 +159,7 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro IsFromApp = true } - ports := simplifyPort(item.Ports) + ports := loadContainerPort(item.Ports) backDatas[i] = dto.ContainerInfo{ ContainerID: item.ID, CreateTime: time.Unix(item.Created, 0).Format("2006-01-02 15:04:05"), @@ -1012,6 +1012,22 @@ func loadVolumeBinds(binds []string) []dto.VolumeHelper { return datas } +func loadContainerPort(ports []types.Port) []string { + var ( + ipv4Ports []types.Port + ipv6Ports []types.Port + ) + for _, port := range ports { + if strings.Contains(port.IP, ":") { + ipv6Ports = append(ipv6Ports, port) + } else { + ipv4Ports = append(ipv4Ports, port) + } + } + list1 := simplifyPort(ipv4Ports) + list2 := simplifyPort(ipv6Ports) + return append(list1, list2...) +} func simplifyPort(ports []types.Port) []string { var datas []string if len(ports) == 0 {