From 0919a6ddcdf9ba9c435fffc4a156bfb64d836c9a Mon Sep 17 00:00:00 2001 From: "STeve (Xin) Huang" Date: Tue, 6 Aug 2024 17:02:37 -0400 Subject: [PATCH] Remove hint from `tsh aws` (#45168) --- tool/tsh/common/app_local_proxy.go | 18 ++++-------------- tool/tsh/common/proxy.go | 5 +++++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tool/tsh/common/app_local_proxy.go b/tool/tsh/common/app_local_proxy.go index ab7fba8de5a86..619a39859e608 100644 --- a/tool/tsh/common/app_local_proxy.go +++ b/tool/tsh/common/app_local_proxy.go @@ -60,10 +60,6 @@ func (a *localProxyApp) StartLocalProxy(ctx context.Context, opts ...alpnproxy.L if err := a.startLocalALPNProxy(ctx, a.port, false /*withTLS*/, opts...); err != nil { return trace.Wrap(err) } - - if a.port == "" { - fmt.Println("To avoid port randomization, you can choose the listening port using the --port flag.") - } return nil } @@ -72,10 +68,6 @@ func (a *localProxyApp) StartLocalProxyWithTLS(ctx context.Context, opts ...alpn if err := a.startLocalALPNProxy(ctx, a.port, true /*withTLS*/, opts...); err != nil { return trace.Wrap(err) } - - if a.port == "" { - fmt.Println("To avoid port randomization, you can choose the listening port using the --port flag.") - } return nil } @@ -88,10 +80,6 @@ func (a *localProxyApp) StartLocalProxyWithForwarder(ctx context.Context, forwar if err := a.startLocalForwardProxy(ctx, a.port, forwardMatcher); err != nil { return trace.Wrap(err) } - - if a.port == "" { - fmt.Println("To avoid port randomization, you can choose the listening port using the --port flag.") - } return nil } @@ -154,8 +142,6 @@ func (a *localProxyApp) startLocalALPNProxy(ctx context.Context, port string, wi return trace.Wrap(err) } - fmt.Printf("Proxying connections to %s on %v\n", a.appInfo.RouteToApp.Name, a.localALPNProxy.GetAddr()) - go func() { if err = a.localALPNProxy.Start(ctx); err != nil { log.WithError(err).Errorf("Failed to start local ALPN proxy.") @@ -206,3 +192,7 @@ func (a *localProxyApp) startLocalForwardProxy(ctx context.Context, port string, }() return nil } + +func (a *localProxyApp) GetAddr() string { + return a.localALPNProxy.GetAddr() +} diff --git a/tool/tsh/common/proxy.go b/tool/tsh/common/proxy.go index 53866dede32ec..fca65feafb46d 100644 --- a/tool/tsh/common/proxy.go +++ b/tool/tsh/common/proxy.go @@ -396,6 +396,11 @@ func onProxyCommandApp(cf *CLIConf) error { return trace.Wrap(err) } + fmt.Printf("Proxying connections to %s on %v\n", cf.AppName, proxyApp.GetAddr()) + if cf.LocalProxyPort == "" { + fmt.Println("To avoid port randomization, you can choose the listening port using the --port flag.") + } + defer func() { if err := proxyApp.Close(); err != nil { log.WithError(err).Error("Failed to close app proxy.")