diff --git a/cmd/cloudflared/tunnel/configuration.go b/cmd/cloudflared/tunnel/configuration.go index 9fddcf7a..8986c9f9 100644 --- a/cmd/cloudflared/tunnel/configuration.go +++ b/cmd/cloudflared/tunnel/configuration.go @@ -203,11 +203,14 @@ func prepareTunnelConfig( TLSClientConfig: &tls.Config{RootCAs: originCertPool, InsecureSkipVerify: c.IsSet("no-tls-verify")}, } - dialContext := (&net.Dialer{ + dialer := &net.Dialer{ Timeout: c.Duration("proxy-connect-timeout"), KeepAlive: c.Duration("proxy-tcp-keepalive"), - DualStack: !c.Bool("proxy-no-happy-eyeballs"), - }).DialContext + } + if c.Bool("proxy-no-happy-eyeballs") { + dialer.FallbackDelay = -1 // As of Golang 1.12, a negative delay disables "happy eyeballs" + } + dialContext := dialer.DialContext if c.IsSet("unix-socket") { unixSocket, err := config.ValidateUnixSocket(c) diff --git a/connection/manager.go b/connection/manager.go index 7d9727e1..bb8d5e23 100644 --- a/connection/manager.go +++ b/connection/manager.go @@ -202,7 +202,7 @@ func (em *EdgeManager) dialEdge(ctx context.Context, edgeIP *net.TCPAddr) (*tls. dialCtx, dialCancel := context.WithTimeout(ctx, timeout) defer dialCancel() - dialer := net.Dialer{DualStack: true} + dialer := net.Dialer{} edgeConn, err := dialer.DialContext(dialCtx, "tcp", edgeIP.String()) if err != nil { return nil, dialError{cause: errors.Wrap(err, "DialContext error")} diff --git a/origin/tunnel.go b/origin/tunnel.go index 86a50a16..81605025 100644 --- a/origin/tunnel.go +++ b/origin/tunnel.go @@ -465,7 +465,7 @@ type TunnelHandler struct { noChunkedEncoding bool } -var dialer = net.Dialer{DualStack: true} +var dialer = net.Dialer{} // NewTunnelHandler returns a TunnelHandler, origin LAN IP and error func NewTunnelHandler(ctx context.Context, diff --git a/tunnelrpc/pogs/config.go b/tunnelrpc/pogs/config.go index ac204484..a15caca3 100644 --- a/tunnelrpc/pogs/config.go +++ b/tunnelrpc/pogs/config.go @@ -197,11 +197,14 @@ func (hc *HTTPOriginConfig) Service() (originservice.OriginService, error) { return nil, err } - dialContext := (&net.Dialer{ + dialer := &net.Dialer{ Timeout: hc.ProxyConnectionTimeout, KeepAlive: hc.TCPKeepAlive, - DualStack: hc.DialDualStack, - }).DialContext + } + if !hc.DialDualStack { + dialer.FallbackDelay = -1 + } + dialContext := dialer.DialContext transport := &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: dialContext, @@ -270,7 +273,6 @@ func (*HelloWorldOriginConfig) Service() (originservice.OriginService, error) { DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, - DualStack: true, }).DialContext, TLSClientConfig: &tls.Config{ RootCAs: rootCAs,