mirror of https://github.com/k3s-io/k3s
If tunnel session does not exist fallback to default dialer
parent
3ff64baab8
commit
3396a7b099
|
@ -21,14 +21,18 @@ func setupTunnel() http.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupProxyDialer(tunnelServer *remotedialer.Server) {
|
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)
|
_, port, _ := net.SplitHostPort(address)
|
||||||
addr := "127.0.0.1"
|
addr := "127.0.0.1"
|
||||||
if port != "" {
|
if port != "" {
|
||||||
addr += ":" + port
|
addr += ":" + port
|
||||||
}
|
}
|
||||||
nodeName, _ := kv.Split(address, ":")
|
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