Documentation
¶
Index ¶
Constants ¶
const ( ResponseEnterPassword = "Please enter password" ResponseAuthSuccess = "Logon successful." ResponseAuthIncorrectPassword = "Password incorrect, please enter password:" ResponseAuthTooManyFails = "Too many failed login attempts!" ResponseWelcome = "Press 'help' to get a list of all commands. Press 'exit' to end session." // ResponseINFLayout is the template for the logline about the command // received by the server. ResponseINFLayout = "INF Executing command '%s' by Telnet from %s" )
Remote server response messages.
const CRLF = "\r\n"
CRLF moves the cursor to the next line and then moves it to the beginning.
const DefaultDialTimeout = 5 * time.Second
DefaultDialTimeout provides default auth timeout to remote server.
const DefaultExitCommand = "exit"
DefaultExitCommand provides default TELNET exit command.
const ExecuteTickTimeout = 1 * time.Second
ExecuteTickTimeout is execute read timeout.
const ForcedExitCommand = ":q"
ForcedExitCommand provides forced TELNET exit command.
const MaxCommandLen = 1000
MaxCommandLen is an artificial restriction, but it will help in case of random large queries.
const NullString = "\x00"
NullString is a null byte in string format.
const ReceiveWaitPeriod = 3 * time.Millisecond
ReceiveWaitPeriod is a delay to receive data from the server.
Variables ¶
var ( // ErrAuthFailed is returned when 7 Days to Die server rejected // sent password. ErrAuthFailed = errors.New("authentication failed") // ErrAuthUnexpectedMessage is returned when 7 Days to Die server responses // without ResponseAuthSuccess or ResponseAuthIncorrectPassword // on auth request. ErrAuthUnexpectedMessage = errors.New("unexpected authentication response") // ErrCommandTooLong is returned when executed command length is bigger // than MaxCommandLen characters. ErrCommandTooLong = errors.New("command too long") // ErrCommandEmpty is returned when executed command length equal 0. ErrCommandEmpty = errors.New("command too small") // ErrMultiErrorOccurred is returned when close connection failed with // error after auth failed. ErrMultiErrorOccurred = errors.New("an error occurred while handling another error") )
var DefaultSettings = Settings{ // contains filtered or unexported fields }
DefaultSettings provides default deadline settings to Conn.
Functions ¶
func DialInteractive ¶
func DialInteractive(r io.Reader, w io.Writer, address string, password string, options ...Option) error
DialInteractive parses commands from input reader, executes them on remote server and writes responses to output writer. Password can be empty string. In this case password will be prompted in an interactive window.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is TELNET connection.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the remote network address.
type Option ¶
type Option func(s *Settings)
Option allows to inject settings to Settings.
func SetClearResponse ¶ added in v1.1.0
SetClearResponse injects clearResponse option to telnet client.
func SetDialTimeout ¶
SetDialTimeout injects dial Timeout to Settings.
func SetExitCommand ¶
SetExitCommand injects telnet exit command.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package telnettest contains TELNET server for TELNET client testing.
|
Package telnettest contains TELNET server for TELNET client testing. |