Files
coder/pty/pty.go
Kyle Carberry 503d09c149 feat: Add support for executing processes with Windows ConPty (#311)
* Initial agent

* fix: Use buffered reader in peer to fix ShortBuffer

This prevents a io.ErrShortBuffer from occurring when the byte
slice being read is smaller than the chunks sent from the opposite
pipe.

This makes sense for unordered connections, where transmission is
not guarunteed, but does not make sense for TCP-like connections.

We use a bufio.Reader when ordered to ensure data isn't lost.

* SSH server works!

* Start Windows support

* Something works

* Refactor pty package to support Windows spawn

* SSH server now works on Windows

* Fix non-Windows

* Fix Linux PTY render

* FIx linux build tests

* Remove agent and wintest

* Add test for Windows resize

* Fix linting errors

* Add Windows environment variables

* Add strings import

* Add comment for attrs

* Add goleak

* Add require import
2022-02-17 10:44:49 -06:00

40 lines
793 B
Go

package pty
import (
"io"
)
// PTY is a minimal interface for interacting with a TTY.
type PTY interface {
io.Closer
// Output handles TTY output.
//
// cmd.SetOutput(pty.Output()) would be used to specify a command
// uses the output stream for writing.
//
// The same stream could be read to validate output.
Output() io.ReadWriter
// Input handles TTY input.
//
// cmd.SetInput(pty.Input()) would be used to specify a command
// uses the PTY input for reading.
//
// The same stream would be used to provide user input: pty.Input().Write(...)
Input() io.ReadWriter
// Resize sets the size of the PTY.
Resize(cols uint16, rows uint16) error
}
// New constructs a new Pty.
func New() (PTY, error) {
return newPty()
}
type readWriter struct {
io.Reader
io.Writer
}