Leave an IPv6 loopback mapping out of what a container publishes, reading ports from the end (hq ADR 0100)

This commit is contained in:
2026-09-22 17:58:50 +02:00
parent 8db66e9532
commit a82bfb41f2
2 changed files with 17 additions and 13 deletions
+5 -13
View File
@@ -123,22 +123,14 @@ func Published(resources []map[string]any) map[string]map[int]int {
protocol := "tcp"
if cut := strings.LastIndex(written, "/"); cut >= 0 {
protocol = written[cut+1:]
written = written[:cut]
}
parts := strings.Split(written, ":")
if len(parts) < 2 {
// Indexed from the end, so an IPv6 address's own colons never shift the ports.
outer, inner, address, ok := mapping(written)
if !ok {
continue
}
if len(parts) == 3 && (parts[0] == "127.0.0.1" || parts[0] == "localhost" ||
parts[0] == "[::1]") {
continue
}
outer, err := strconv.Atoi(parts[len(parts)-2])
if err != nil {
continue
}
inner, err := strconv.Atoi(parts[len(parts)-1])
if err != nil {
switch strings.Trim(address, "[]") {
case "127.0.0.1", "localhost", "::1":
continue
}
if out[protocol] == nil {