Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49bf5b80c8 | ||
|
|
24852b6b3f | ||
|
|
bbc689cf5c |
@@ -4,8 +4,8 @@ go 1.23.0
|
||||
|
||||
require (
|
||||
golang.org/x/net v0.21.0 // tagx:ignore
|
||||
golang.org/x/sys v0.30.0
|
||||
golang.org/x/term v0.29.0
|
||||
golang.org/x/sys v0.31.0
|
||||
golang.org/x/term v0.30.0
|
||||
)
|
||||
|
||||
require golang.org/x/text v0.22.0 // indirect
|
||||
require golang.org/x/text v0.23.0 // indirect
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
|
||||
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
|
||||
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
|
||||
@@ -818,6 +818,8 @@ func decode(packet []byte) (interface{}, error) {
|
||||
return new(userAuthSuccessMsg), nil
|
||||
case msgUserAuthFailure:
|
||||
msg = new(userAuthFailureMsg)
|
||||
case msgUserAuthBanner:
|
||||
msg = new(userAuthBannerMsg)
|
||||
case msgUserAuthPubKeyOk:
|
||||
msg = new(userAuthPubKeyOkMsg)
|
||||
case msgGlobalRequest:
|
||||
|
||||
@@ -206,6 +206,62 @@ func TestMarshalMultiTag(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecode(t *testing.T) {
|
||||
rnd := rand.New(rand.NewSource(0))
|
||||
kexInit := new(kexInitMsg).Generate(rnd, 10).Interface()
|
||||
kexDHInit := new(kexDHInitMsg).Generate(rnd, 10).Interface()
|
||||
kexDHReply := new(kexDHReplyMsg)
|
||||
kexDHReply.Y = randomInt(rnd)
|
||||
// Note: userAuthSuccessMsg can't be tested directly since it
|
||||
// doesn't have a field for sshtype. So it's tested separately
|
||||
// at the end.
|
||||
decodeMessageTypes := []interface{}{
|
||||
new(disconnectMsg),
|
||||
new(serviceRequestMsg),
|
||||
new(serviceAcceptMsg),
|
||||
new(extInfoMsg),
|
||||
kexInit,
|
||||
kexDHInit,
|
||||
kexDHReply,
|
||||
new(userAuthRequestMsg),
|
||||
new(userAuthFailureMsg),
|
||||
new(userAuthBannerMsg),
|
||||
new(userAuthPubKeyOkMsg),
|
||||
new(globalRequestMsg),
|
||||
new(globalRequestSuccessMsg),
|
||||
new(globalRequestFailureMsg),
|
||||
new(channelOpenMsg),
|
||||
new(channelDataMsg),
|
||||
new(channelOpenConfirmMsg),
|
||||
new(channelOpenFailureMsg),
|
||||
new(windowAdjustMsg),
|
||||
new(channelEOFMsg),
|
||||
new(channelCloseMsg),
|
||||
new(channelRequestMsg),
|
||||
new(channelRequestSuccessMsg),
|
||||
new(channelRequestFailureMsg),
|
||||
new(userAuthGSSAPIToken),
|
||||
new(userAuthGSSAPIMIC),
|
||||
new(userAuthGSSAPIErrTok),
|
||||
new(userAuthGSSAPIError),
|
||||
}
|
||||
for _, msg := range decodeMessageTypes {
|
||||
decoded, err := decode(Marshal(msg))
|
||||
if err != nil {
|
||||
t.Errorf("error decoding %T", msg)
|
||||
} else if reflect.TypeOf(msg) != reflect.TypeOf(decoded) {
|
||||
t.Errorf("error decoding %T, unexpected %T", msg, decoded)
|
||||
}
|
||||
}
|
||||
|
||||
userAuthSuccess, err := decode([]byte{msgUserAuthSuccess})
|
||||
if err != nil {
|
||||
t.Errorf("error decoding userAuthSuccessMsg")
|
||||
} else if reflect.TypeOf(userAuthSuccess) != reflect.TypeOf((*userAuthSuccessMsg)(nil)) {
|
||||
t.Errorf("error decoding userAuthSuccessMsg, unexpected %T", userAuthSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
func randomBytes(out []byte, rand *rand.Rand) {
|
||||
for i := 0; i < len(out); i++ {
|
||||
out[i] = byte(rand.Int31())
|
||||
|
||||
+1
-1
@@ -459,7 +459,7 @@ func (c *Client) dial(laddr string, lport int, raddr string, rport int) (Channel
|
||||
return nil, err
|
||||
}
|
||||
go DiscardRequests(in)
|
||||
return ch, err
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
type tcpChan struct {
|
||||
|
||||
Reference in New Issue
Block a user