Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod: improve compatibility for xshell7 #90

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions app/xshell.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ type signRequestAgentMsg struct {
Flags uint32
}

type signRequestAgentMsgXshell7 struct {
KeyBlob []byte `sshtype:"13"`
Data []byte
Flags uint32
Others uint64
}

func (s *xshellProxy) Read(p []byte) (n int, err error) {
if len(s.buf) > 0 {
n := copy(p, s.buf)
Expand All @@ -163,10 +170,22 @@ func (s *xshellProxy) Read(p []byte) (n int, err error) {
}
// sign
if s.buf[4] == agentSignRequest {
var req signRequestAgentMsg
if err := ssh.Unmarshal(s.buf[4:], &req); err != nil {
l += 4
s.buf = append(s.buf, []byte{0, 0, 0, 0}...)
success := false
{
var req signRequestAgentMsgXshell7
if err := ssh.Unmarshal(s.buf[4:], &req); err == nil {
l -= 4
nl := len(s.buf) - 4
s.buf = s.buf[:nl]
success = true
}
}
if !success {
var req signRequestAgentMsg
if err := ssh.Unmarshal(s.buf[4:], &req); err != nil {
l += 4
s.buf = append(s.buf, []byte{0, 0, 0, 0}...)
}
}
}
binary.BigEndian.PutUint32(s.buf, l)
Expand Down