Documentation
¶
Index ¶
Constants ¶
const ( AuthSuccess = "Logon successful." AuthIncorrectPassword = "Password incorrect, please enter password:" AuthTooManyFails = "Too many failed login attempts!" )
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 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") // 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 SetDialTimeout ¶
SetDialTimeout injects dial Timeout to Settings.
func SetExitCommand ¶
SetExitCommand injects telnet exit command.