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

pull/2447/head
Louis Ruch 3 years ago committed by GitHub
parent 2db6bee3e2
commit 50490d71ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)"
}

@ -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

Loading…
Cancel
Save