Skip to content

Commit

Permalink
Add a dedicated client to communicate with the Proxy SSH server (grav…
Browse files Browse the repository at this point in the history
…itational#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 gravitational#19812
  • Loading branch information
rosstimothy authored Mar 15, 2023
1 parent f02468e commit 1c3188a
Show file tree
Hide file tree
Showing 11 changed files with 1,494 additions and 15 deletions.
6 changes: 3 additions & 3 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, opts ...DialProxyOption) 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, opts...)
}
return dialer.DialContext(ctx, network, addr)
Expand Down Expand Up @@ -116,7 +116,7 @@ func NewProxyDialer(ssh ssh.ClientConfig, keepAlivePeriod, dialTimeout time.Dura
func newTunnelDialer(ssh ssh.ClientConfig, keepAlivePeriod, dialTimeout time.Duration, opts ...DialProxyOption) ContextDialer {
dialer := newDirectDialer(keepAlivePeriod, dialTimeout)
return ContextDialerFunc(func(ctx context.Context, network, addr string) (conn net.Conn, err error) {
if proxyURL := proxy.GetProxyURL(addr); proxyURL != nil {
if proxyURL := utils.GetProxyURL(addr); proxyURL != nil {
conn, err = DialProxyWithDialer(ctx, proxyURL, addr, dialer, opts...)
} else {
conn, err = dialer.DialContext(ctx, network, addr)
Expand Down
Loading

0 comments on commit 1c3188a

Please sign in to comment.