mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #1344 from ibuildthecloud/dialer-fallback
If tunnel session does not exist fallback to default dialer
This commit is contained in:
commit
3592d0bdd9
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user