Skip to content

Instantly share code, notes, and snippets.

@seysn
Created November 26, 2018 16:19
Show Gist options
  • Save seysn/64a8031a0ea0d0b50667fd0302081a9f to your computer and use it in GitHub Desktop.
Save seysn/64a8031a0ea0d0b50667fd0302081a9f to your computer and use it in GitHub Desktop.
//
// $GOPATH/src/golang.org/x/crypto/ssh/transport.go
//
// Read version string as specified by RFC 4253, section 4.2.
func readVersion(r io.Reader) ([]byte, error) {
// Empty Read buffer
var buf [1]byte
for length := 0; length < maxVersionStringBytes; length++ {
_, err := io.ReadFull(r, buf[:])
if err != nil {
return nil, err
}
if buf[0] == '\n' {
break
}
}
// Replace the dummy versionString with the correct one
versionString := make([]byte, 0, 64)
msg := []byte("SSH-2.0-OpenSSH_7.9")
for _, e := range msg {
versionString = append(versionString, e)
}
return versionString, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment