Documentation
¶
Overview ¶
Package telnet is SSHYard's Telnet client (RFC 854/855) over any byte stream. It negotiates options with the RFC 1143 Q method, answers TERMINAL-TYPE and NAWS, measures round trips with TIMING-MARK, and hands the caller the server's data with the protocol stripped, ready for a terminal emulator.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("telnet: connection closed")
ErrClosed reports a probe cut short by the end of the connection.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a Telnet client session over rw. Read is meant for one goroutine; Write, Resize, Probe and Close may be called from others.
func New ¶
func New(rw io.ReadWriteCloser, o Options) *Conn
New starts a Telnet session on rw and sends the client's opening offers (WILL NAWS, WILL TTYPE, DO ECHO, WILL SGA, DO SGA). A failure to send them shows up on the next Read or Write.
func (*Conn) Probe ¶
Probe measures a round trip with TIMING-MARK (RFC 860): it sends DO TIMING-MARK and waits for the server's WILL or WONT, which the goroutine calling Read picks up, so Read must be running. Probes run one at a time; a concurrent Probe waits its turn. It returns ctx.Err() when ctx ends first and ErrClosed when the connection does.
func (*Conn) Read ¶
Read returns the server's data, protocol stripped. It returns io.EOF itself when the server closes the connection; other errors are returned as the transport gave them.