Skip to content

Commit 8b6ff01

Browse files
authored
Merge pull request #2690 from jwendell/fix-ipv6
Fix a conformance test when running on ipv6
2 parents 8a0e04e + 76156d7 commit 8b6ff01

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

conformance/tests/mesh-frontend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var MeshFrontend = suite.ConformanceTest{
5959
{
6060
TestCaseName: "Send to pod IP",
6161
Request: http.Request{
62-
Host: v2.Address + ":8080",
62+
Host: http.Ipv6SafeHost(v2.Address) + ":8080",
6363
Method: "GET",
6464
},
6565
Response: http.Response{

conformance/utils/http/http.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,19 @@ func CalculateHost(t *testing.T, gwAddr, scheme string) string {
167167
return gwAddr
168168
}
169169
if strings.ToLower(scheme) == "http" && port == "80" {
170-
return ipv6SafeHost(host)
170+
return Ipv6SafeHost(host)
171171
}
172172
if strings.ToLower(scheme) == "https" && port == "443" {
173-
return ipv6SafeHost(host)
173+
return Ipv6SafeHost(host)
174174
}
175175
return gwAddr
176176
}
177177

178-
func ipv6SafeHost(host string) string {
179-
// We assume that host is a literal IPv6 address if host has
180-
// colons.
181-
// Per https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2.
182-
// This is like net.JoinHostPort, but we don't need a port.
178+
// Ipv6SafeHost returns a safe representation for an ipv6 address to be used with a port
179+
// We assume that host is a literal IPv6 address if host has colons.
180+
// Per https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2.
181+
// This is like net.JoinHostPort, but we don't need a port.
182+
func Ipv6SafeHost(host string) string {
183183
if strings.Contains(host, ":") {
184184
return "[" + host + "]"
185185
}

0 commit comments

Comments
 (0)