Version: v0.0.0-...-f99310c Latest Latest

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

Go to latest
Published: Jul 10, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0




View Source
const (
	MaxInteger      = 0x3fff
	MaxIntegerBytes = 2


View Source
const (
	SSHServerRemoteStdOut             = 0x00
	SSHServerRemoteStdErr             = 0x01
	SSHServerConnectFailed            = 0x02
	SSHServerConnectSucceed           = 0x03
	SSHServerConnectVerifyFingerprint = 0x04
	SSHServerConnectRequestCredential = 0x05

Server -> client signal Consts

View Source
const (
	SSHClientStdIn              = 0x00
	SSHClientResize             = 0x01
	SSHClientRespondFingerprint = 0x02
	SSHClientRespondCredential  = 0x03

Client -> server signal consts

View Source
const (
	SSHRequestErrorBadUserName      = command.StreamError(0x01)
	SSHRequestErrorBadRemoteAddress = command.StreamError(0x02)
	SSHRequestErrorBadAuthMethod    = command.StreamError(0x03)

Error codes

View Source
const (
	SSHAuthMethodNone       byte = 0x00
	SSHAuthMethodPassphrase byte = 0x01
	SSHAuthMethodPrivateKey byte = 0x02

Auth methods

View Source
const (
	TelnetServerRemoteBand    = 0x00
	TelnetServerDialFailed    = 0x01
	TelnetServerDialConnected = 0x02

Server signal codes

View Source
const (
	TelnetRequestErrorBadRemoteAddress = command.StreamError(0x01)

Error codes


View Source
var (
	ErrAddressParseBufferTooSmallForHeader = errors.New(
		"Buffer space was too small to parse the address header")

	ErrAddressParseBufferTooSmallForIPv4 = errors.New(
		"Buffer space was too small to parse the IPv4 address")

	ErrAddressParseBufferTooSmallForIPv6 = errors.New(
		"Buffer space was too small to parse the IPv6 address")

	ErrAddressParseBufferTooSmallForHostName = errors.New(
		"Buffer space was too small to parse the hostname address")

	ErrAddressMarshalBufferTooSmall = errors.New(
		"Buffer space was too small to marshal the address")

	ErrAddressInvalidAddressType = errors.New(
		"Invalid address type")


View Source
var (
	ErrIntegerMarshalNotEnoughBuffer = errors.New(
		"Not enough buffer to marshal the integer")

	ErrIntegerMarshalTooLarge = errors.New(
		"Integer cannot be marshalled, because the vaule was too large")


View Source
var (
	ErrSSHAuthCancelled = errors.New(
		"Authentication has been cancelled")

	ErrSSHInvalidAuthMethod = errors.New(
		"Invalid auth method")

	ErrSSHInvalidAddress = errors.New(
		"Invalid address")

	ErrSSHRemoteFingerprintVerificationCancelled = errors.New(
		"Server Fingerprint verification process has been cancelled")

	ErrSSHRemoteFingerprintRefused = errors.New(
		"Server Fingerprint has been refused")

	ErrSSHRemoteConnUnavailable = errors.New(
		"Remote SSH connection is unavailable")

	ErrSSHUnexpectedFingerprintVerificationRespond = errors.New(
		"Unexpected fingerprint verification respond")

	ErrSSHUnexpectedCredentialDataRespond = errors.New(
		"Unexpected credential data respond")

	ErrSSHCredentialDataTooLarge = errors.New(
		"Credential was too large")

	ErrSSHUnknownClientSignal = errors.New(
		"Unknown client signal")


View Source
var (
	ErrStringParseBufferTooSmall = errors.New(
		"Not enough buffer space to parse given string")

	ErrStringMarshalBufferTooSmall = errors.New(
		"Not enough buffer space to marshal given string")


View Source
var (
	ErrTelnetUnableToReceiveRemoteConn = errors.New(
		"Unable to acquire remote connection handle")



func New

func New() command.Commands

New creates a new commands group


type Address

type Address struct {
	// contains filtered or unexported fields

Address data

func NewAddress

func NewAddress(addrType AddressType, data []byte, port uint16) Address

NewAddress creates a new Address

func ParseAddress

func ParseAddress(reader rw.ReaderFunc, buf []byte) (Address, error)

ParseAddress parses the reader and return an Address

Address data format: +-------------+--------------+---------------+ | 2 bytes | 1 byte | n bytes | +-------------+--------------+---------------+ | Port number | Address type | Address data | +-------------+--------------+---------------+

Address types:

- LoopbackAddr:    00 Localhost, don't carry Address data
- IPv4Addr:        01 IPv4 Address, carries 4 bytes of Address data
- IPv6Addr:        10 IPv6 Address, carries 16 bytes Address data
- HostnameAddr:    11 Host name string, length of Address data is indicated
                      by the remainer of the byte (11-- ----). maxlen = 63

func (Address) Data

func (a Address) Data() []byte

Data returns the address data

func (Address) Marshal

func (a Address) Marshal(b []byte) (int, error)

Marshal writes address data to the given b

func (Address) Port

func (a Address) Port() uint16

Port returns port number

func (Address) String

func (a Address) String() string

String return the Address as string

func (Address) Type

func (a Address) Type() AddressType

Type returns the type of the address

type AddressType

type AddressType byte

AddressType Type of the address

const (
	LoopbackAddr AddressType = 0x00
	IPv4Addr     AddressType = 0x01
	IPv6Addr     AddressType = 0x02
	HostNameAddr AddressType = 0x03

Address types

type Integer

type Integer uint16

Integer is a 16bit unsigned integer data

Format: +-------------------------------------+--------------+ | 1 bit | 7 bits | +-------------------------------------+--------------+ | 1 when current byte is the end byte | Integer data | +-------------------------------------+--------------+


- 00000000 00000000: 0
- 01111111:          127
- 11111111 01000000: 255

func (*Integer) ByteSize

func (i *Integer) ByteSize() int

ByteSize returns how many bytes current integer will be encoded into

func (*Integer) Int

func (i *Integer) Int() int

Int returns a int of current Integer

func (*Integer) Marshal

func (i *Integer) Marshal(b []byte) (int, error)

Marshal build serialized data of the integer

func (*Integer) Unmarshal

func (i *Integer) Unmarshal(reader rw.ReaderFunc) error

Unmarshal read data and parse the integer

type String

type String struct {
	// contains filtered or unexported fields

String data

func NewString

func NewString(d []byte) String

NewString create a new String

func ParseString

func ParseString(reader rw.ReaderFunc, b []byte) (String, error)

ParseString build the String according to readed data

func (String) Data

func (s String) Data() []byte

Data returns the data of the string

func (String) Marshal

func (s String) Marshal(b []byte) (int, error)

Marshal the string to give buffer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL