Skip to content

proposal: x/crypto/ssh: export disconnectMsg error type #65186

Open
@dblueman

Description

@dblueman

Go version

1.12.1

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/daniel/.cache/go-build'
GOENV='/home/daniel/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/daniel/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/daniel/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go-1.21'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go-1.21/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build835199979=/tmp/go-build -gno-record-gcc-switches'

What did you do?

When checking for a particular case where the SSH session should be closed and restablished, I am using a workaround:
err.Error() == "ssh: disconnect, reason 11:"

What did you see happen?

String-comparing the error message works but is brittle and non-optimal.

What did you expect to see?

We would expect type disconnectMsg to be exported (ie DisconnectMsg) to allow comparison via:
sErr ssh.DisconnectMsg if errors.As(err, &sErr) && sErr.Reason == 11) { ...
or just:
if errors.Is(err, ssh.DisconnectMsg) { ...

Similar error types, for example ExitError are exported for this rationale.

I can prepare a non-breaking (API compatible) Pull Request to address this issue if there are no objections?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalProposal-CryptoProposal related to crypto packages or other security issues

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions