chore(targets): Improve help and errors around ssh targets (#2445)

This commit is contained in:
Louis Ruch authored and GitHub committed 2022-09-13 13:05:36 -07:00
1 parent 2db6bee3e2
commit 50490d71ae
2 files changed
+7 -2

No files matched your search

@@ -14,6 +14,7 @@ func init() {
extraSshActionsFlagsMapFunc = extraSshActionsFlagsMapFuncImpl
extraSshFlagsFunc = extraSshFlagsFuncImpl
extraSshFlagsHandlingFunc = extraSshFlagsHandlingFuncImpl
extraSshSynopsisFunc = extraSshSynopsisFuncImpl
}
func extraSshActionsFlagsMapFuncImpl() map[string][]string {
@@ -152,3 +153,7 @@ func extraSshFlagsHandlingFuncImpl(c *SshCommand, _ *base.FlagSets, opts *[]targ
return true
}
func extraSshSynopsisFuncImpl(_ *SshCommand) string {
return "Create a ssh-type target (HCP only)"
}
+2 -2
View File
@@ -184,7 +184,7 @@ func (w *Worker) handleProxy(listenerCfg *listenerutil.ListenerConfig, sessionMa
endpointUrl, err := url.Parse(sess.GetEndpoint())
if err != nil {
event.WriteError(ctx, op, err, event.WithInfoMsg("worker failed to parse target endpoint", "endpoint", sess.GetEndpoint()))
if err = conn.Close(websocket.StatusProtocolError, "unsupported-protocol"); err != nil {
if err = conn.Close(websocket.StatusProtocolError, "unable to parse endpoint"); err != nil {
event.WriteError(ctx, op, err, event.WithInfoMsg("error closing client connection"))
}
return
@@ -192,7 +192,7 @@ func (w *Worker) handleProxy(listenerCfg *listenerutil.ListenerConfig, sessionMa
handleProxyFn, err := proxyHandlers.GetHandler(endpointUrl.Scheme)
if err != nil {
event.WriteError(ctx, op, err, event.WithInfoMsg("worker received request for unsupported protocol", "protocol", endpointUrl.Scheme))
if err = conn.Close(websocket.StatusProtocolError, "unsupported-protocol"); err != nil {
if err = conn.Close(websocket.StatusProtocolError, fmt.Sprintf("worker does not support %q type", endpointUrl.Scheme)); err != nil {
event.WriteError(ctx, op, err, event.WithInfoMsg("error closing client connection"))
}
return