Commit a98b4c90 authored by Matt Joiner's avatar Matt Joiner

Fix for hosts that don't have localhost->::1 for IPv6

parent ea6dd6cf
......@@ -9,17 +9,17 @@ import (
"github.com/stretchr/testify/require"
)
func testDialFromListeningPort(t *testing.T, network string) {
func testDialFromListeningPort(t *testing.T, network, host string) {
lc := net.ListenConfig{
Control: Control,
}
ctx := context.Background()
ll, err := lc.Listen(ctx, network, "localhost:0")
ll, err := lc.Listen(ctx, network, host+":0")
if err != nil && strings.Contains(err.Error(), "cannot assign requested address") {
t.Skip(err)
}
require.NoError(t, err)
rl, err := lc.Listen(ctx, network, "localhost:0")
rl, err := lc.Listen(ctx, network, host+":0")
require.NoError(t, err)
d := net.Dialer{
LocalAddr: ll.Addr(),
......@@ -31,9 +31,9 @@ func testDialFromListeningPort(t *testing.T, network string) {
}
func TestDialFromListeningPort(t *testing.T) {
testDialFromListeningPort(t, "tcp")
testDialFromListeningPort(t, "tcp", "localhost")
}
func TestDialFromListeningPortTcp6(t *testing.T) {
testDialFromListeningPort(t, "tcp6")
testDialFromListeningPort(t, "tcp6", "[::1]")
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment