Skip to content

Commit

Permalink
[v11] Proxy Client (#24737)
Browse files Browse the repository at this point in the history
* Add a dedicated client to communicate with the Proxy SSH server (#22629)

A new `api/client/proxy/Client` has been added to interact with
the SSH and gRPC servers that the Proxy serves on its SSH port.
The client will first try connecting to the gRPC server and if
that fails it will fall back to the SSH server.

Much of the SSH functionality mimics the existing behavior of the
`ProxyClient` in `lib/client`. This is the first part of phasing
out that client in favor of the new client. There will be a follow
up PR that migrates `lib/client` to make use of the new client instead.

Part of #19812

* Make `proxy.Client` infer the cluster name from Proxy (#23644)

Instead of relying on users to provide the cluster name, the client
now determines the cluster name by inspecting the certificate
presented by the Proxy during the TLS or SSH handshake. This is
required when connecting to a Proxy via a jump host since the
name of the cluster may not match the currently logged in cluster.

This is achieved by leveraging a custom `credentials.TransportCredentials`
when connecting via gRPC and a custom `ssh.HostKeyCallback` when
connecting SSH.
  • Loading branch information
rosstimothy authored Apr 21, 2023
1 parent 18b38cc commit 92a9ab1
Show file tree
Hide file tree
Showing 11 changed files with 1,131 additions and 14 deletions.
4 changes: 2 additions & 2 deletions api/client/contextdialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
oteltrace "go.opentelemetry.io/otel/trace"
"golang.org/x/crypto/ssh"

"github.com/gravitational/teleport/api/client/proxy"
"github.com/gravitational/teleport/api/client/webclient"
"github.com/gravitational/teleport/api/constants"
"github.com/gravitational/teleport/api/observability/tracing"
tracessh "github.com/gravitational/teleport/api/observability/tracing/ssh"
"github.com/gravitational/teleport/api/utils"
"github.com/gravitational/teleport/api/utils/sshutils"
)

Expand Down Expand Up @@ -81,7 +81,7 @@ func tracedDialer(ctx context.Context, fn ContextDialerFunc) ContextDialerFunc {
func NewDialer(ctx context.Context, keepAlivePeriod, dialTimeout time.Duration) ContextDialer {
return tracedDialer(ctx, func(ctx context.Context, network, addr string) (net.Conn, error) {
dialer := newDirectDialer(keepAlivePeriod, dialTimeout)
if proxyURL := proxy.GetProxyURL(addr); proxyURL != nil {
if proxyURL := utils.GetProxyURL(addr); proxyURL != nil {
return DialProxyWithDialer(ctx, proxyURL, addr, dialer)
}
return dialer.DialContext(ctx, network, addr)
Expand Down
Loading

0 comments on commit 92a9ab1

Please sign in to comment.