mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
* 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
40 lines
793 B
Go
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
|
|
}
|