Unverified Commit 3592d0bd authored by Erik Wilson's avatar Erik Wilson Committed by GitHub

Merge pull request #1344 from ibuildthecloud/dialer-fallback

If tunnel session does not exist fallback to default dialer
parents 1a2690d7 3396a7b0
......@@ -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)
})
}
......
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