telnet

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2024 License: BSD-3-Clause Imports: 6 Imported by: 132

README

Documentation

Overview

Package telnet provides simple interface for interacting with Telnet connection.

Index

Constants

View Source
const (
	CR = byte('\r')
	LF = byte('\n')
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

Conn implements net.Conn interface for Telnet protocol plus some set of Telnet specific methods.

func Dial

func Dial(network, addr string) (*Conn, error)

func DialTimeout

func DialTimeout(network, addr string, timeout time.Duration) (*Conn, error)

func NewConn

func NewConn(conn net.Conn) (*Conn, error)

func (*Conn) Read

func (c *Conn) Read(buf []byte) (int, error)

Read is for implement an io.Reader interface

func (*Conn) ReadByte

func (c *Conn) ReadByte() (b byte, err error)

ReadByte works like bufio.ReadByte

func (*Conn) ReadBytes

func (c *Conn) ReadBytes(delim byte) ([]byte, error)

ReadBytes works like bufio.ReadBytes

func (*Conn) ReadRune

func (c *Conn) ReadRune() (r rune, size int, err error)

ReadRune works like bufio.ReadRune

func (*Conn) ReadString

func (c *Conn) ReadString(delim byte) (string, error)

ReadString works like bufio.ReadString

func (*Conn) ReadUntil

func (c *Conn) ReadUntil(delims ...string) ([]byte, error)

ReadUntil works like ReadUntilIndex but don't return a delimiter index.

func (*Conn) ReadUntilIndex

func (c *Conn) ReadUntilIndex(delims ...string) ([]byte, int, error)

ReadUntilIndex reads from connection until one of delimiters occurs. Returns read data and an index of delimiter or error.

func (*Conn) SetEcho

func (c *Conn) SetEcho(echo bool) error

SetEcho tries to enable/disable echo on server side. Typically telnet servers doesn't support this.

func (*Conn) SetUnixWriteMode

func (c *Conn) SetUnixWriteMode(uwm bool)

SetUnixWriteMode sets flag that applies only to the Write method. If set, Write converts any '\n' (LF) to '\r\n' (CR LF).

func (*Conn) SkipBytes

func (c *Conn) SkipBytes(delim byte) error

SkipBytes works like ReadBytes but skips all read data.

func (*Conn) SkipUntil

func (c *Conn) SkipUntil(delims ...string) error

SkipUntil works like ReadUntil but skips all read data.

func (*Conn) SkipUntilIndex

func (c *Conn) SkipUntilIndex(delims ...string) (int, error)

SkipUntilIndex works like ReadUntilIndex but skips all read data.

func (*Conn) Write

func (c *Conn) Write(buf []byte) (int, error)

Write is for implement an io.Writer interface

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL