Properly create hostname from IPv6 (#7431)

Generate valid hostname from IPv6 when the address ends with `::`.

Signed-off-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
This commit is contained in:
Guillaume Jacquet
2025-08-04 19:53:40 -04:00
committed by GitHub
parent 17020f09a8
commit 1025a199e9
2 changed files with 7 additions and 1 deletions

View File

@@ -351,7 +351,11 @@ func endpointHostname(addr object.EndpointAddress, endpointNameMode bool) string
return strings.ReplaceAll(addr.IP, ".", "-")
}
if strings.Contains(addr.IP, ":") {
return strings.ReplaceAll(addr.IP, ":", "-")
ipv6Hostname := strings.ReplaceAll(addr.IP, ":", "-")
if strings.HasSuffix(ipv6Hostname, "-") {
return ipv6Hostname + "0"
}
return ipv6Hostname
}
return ""
}