// Close closes the channel. This does not close the underlying connection.
func (c *clientChan) Close() error {
return c.writePacket(marshal(msgChannelClose, channelCloseMsg{
- PeersId: c.id,
+ PeersId: c.peersId,
}))
}
// A chanWriter represents the stdin of a remote process.
type chanWriter struct {
win chan int // receives window adjustments
- id uint32 // this channel's id
+ peersId uint32 // the peers id
rwin int // current rwin size
packetWriter // for sending channelDataMsg
}
n = len(data)
packet := make([]byte, 0, 9+n)
packet = append(packet, msgChannelData,
- byte(w.id)>>24, byte(w.id)>>16, byte(w.id)>>8, byte(w.id),
+ byte(w.peersId)>>24, byte(w.peersId)>>16, byte(w.peersId)>>8, byte(w.peersId),
byte(n)>>24, byte(n)>>16, byte(n)>>8, byte(n))
err = w.writePacket(append(packet, data...))
w.rwin -= n
}
func (w *chanWriter) Close() error {
- return w.writePacket(marshal(msgChannelEOF, channelEOFMsg{w.id}))
+ return w.writePacket(marshal(msgChannelEOF, channelEOFMsg{w.peersId}))
}
// A chanReader represents stdout or stderr of a remote process.
// If writes to this channel block, they will block mainLoop, making
// it unable to receive new messages from the remote side.
data chan []byte // receives data from remote
- id uint32
- packetWriter // for sending windowAdjustMsg
+ peersId uint32 // the peers id
+ packetWriter // for sending windowAdjustMsg
buf []byte
}
n := copy(data, r.buf)
r.buf = r.buf[n:]
msg := windowAdjustMsg{
- PeersId: r.id,
+ PeersId: r.peersId,
AdditionalBytes: uint32(n),
}
return n, r.writePacket(marshal(msgChannelWindowAdjust, msg))
}
panic("unreachable")
}
-
-func (r *chanReader) Close() error {
- return r.writePacket(marshal(msgChannelEOF, channelEOFMsg{r.id}))
-}
// command executed by Shell or Exec.
func (s *Session) Setenv(name, value string) error {
req := setenvRequest{
- PeersId: s.id,
+ PeersId: s.peersId,
Request: "env",
WantReply: true,
Name: name,
// RequestPty requests the association of a pty with the session on the remote host.
func (s *Session) RequestPty(term string, h, w int) error {
req := ptyRequestMsg{
- PeersId: s.id,
+ PeersId: s.peersId,
Request: "pty-req",
WantReply: true,
Term: term,
return errors.New("ssh: session already started")
}
req := execMsg{
- PeersId: s.id,
+ PeersId: s.peersId,
Request: "exec",
WantReply: true,
Command: cmd,
return errors.New("ssh: session already started")
}
req := channelRequestMsg{
- PeersId: s.id,
+ PeersId: s.peersId,
Request: "shell",
WantReply: true,
}
s.copyFuncs = append(s.copyFuncs, func() error {
_, err := io.Copy(&chanWriter{
packetWriter: s,
- id: s.id,
+ peersId: s.peersId,
win: s.win,
}, s.Stdin)
return err
s.copyFuncs = append(s.copyFuncs, func() error {
_, err := io.Copy(s.Stdout, &chanReader{
packetWriter: s,
- id: s.id,
+ peersId: s.peersId,
data: s.data,
})
return err
s.copyFuncs = append(s.copyFuncs, func() error {
_, err := io.Copy(s.Stderr, &chanReader{
packetWriter: s,
- id: s.id,
+ peersId: s.peersId,
data: s.dataExt,
})
return err