From 64323d22d9542e981a4dc6777fa26c9c7a5caf9c Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 20 Feb 2021 00:24:52 +0100 Subject: Emulate golang's ListenTCP --- pkg/tcpip/adapters/gonet/gonet.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/tcpip/adapters/gonet/gonet.go b/pkg/tcpip/adapters/gonet/gonet.go index c188aaa18..2c5a654f3 100644 --- a/pkg/tcpip/adapters/gonet/gonet.go +++ b/pkg/tcpip/adapters/gonet/gonet.go @@ -72,6 +72,9 @@ func ListenTCP(s *stack.Stack, addr tcpip.FullAddress, network tcpip.NetworkProt return nil, errors.New(err.String()) } + // Emulate golang's ListenTCP which is always ipv4-only or ipv6-only + ep.SocketOptions().SetV6Only(true) + if err := ep.Bind(addr); err != nil { ep.Close() return nil, &net.OpError{ -- cgit v1.2.3