From 3396a7b099e3879368386a4a2336ffec1c1a1955 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 22 Jan 2020 10:57:51 -0700 Subject: [PATCH] If tunnel session does not exist fallback to default dialer --- pkg/daemons/control/tunnel.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/daemons/control/tunnel.go b/pkg/daemons/control/tunnel.go index 6e1d591ac0..4c758bc64f 100644 --- a/pkg/daemons/control/tunnel.go +++ b/pkg/daemons/control/tunnel.go @@ -21,14 +21,18 @@ func setupTunnel() http.Handler { } func setupProxyDialer(tunnelServer *remotedialer.Server) { - app.DefaultProxyDialerFn = utilnet.DialFunc(func(_ context.Context, network, address string) (net.Conn, error) { + app.DefaultProxyDialerFn = utilnet.DialFunc(func(ctx context.Context, network, address string) (net.Conn, error) { _, port, _ := net.SplitHostPort(address) addr := "127.0.0.1" if port != "" { addr += ":" + port } nodeName, _ := kv.Split(address, ":") - return tunnelServer.Dial(nodeName, 15*time.Second, "tcp", addr) + if tunnelServer.HasSession(nodeName) { + return tunnelServer.Dial(nodeName, 15*time.Second, "tcp", addr) + } + var d net.Dialer + return d.DialContext(ctx, network, address) }) }