transport

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTransport is the default transport constant for scrapligo, this defaults to the
	// "system" transport.
	DefaultTransport = "system"

	// InChannelAuthUnsupported indicates that the transport does *not* support in channel auth.
	InChannelAuthUnsupported = "in-channel-auth-unsupported"
	// InChannelAuthSSH indicates that the transport supports in channel ssh auth.
	InChannelAuthSSH = "in-channel-auth-ssh"
	// InChannelAuthTelnet indicates that the transport supports in channel telnet auth.
	InChannelAuthTelnet = "in-channel-auth-telnet"
)
View Source
const (
	// FileTransport transport name.
	FileTransport = "file"
)
View Source
const (
	// StandardTransport is the standard (crypto/ssh) transport for scrapligo.
	StandardTransport = "standard"
)
View Source
const (
	// SystemTransport is the default "system" (/bin/ssh wrapper) transport for scrapligo.
	SystemTransport = "system"
)
View Source
const (
	// TelnetTransport is the telnet transport for scrapligo.
	TelnetTransport = "telnet"
)

Variables

This section is empty.

Functions

func GetNetconfTransportNames

func GetNetconfTransportNames() []string

GetNetconfTransportNames returns a slice of available NETCONF transport type names.

func GetTransportNames

func GetTransportNames() []string

GetTransportNames is returns a slice of available transport type names.

Types

type Args

type Args struct {
	Host          string
	Port          int
	User          string
	Password      string
	TimeoutSocket time.Duration
	ReadSize      int
	TermHeight    int
	TermWidth     int
	// contains filtered or unexported fields
}

Args is a struct representing common transport arguments.

func NewArgs

func NewArgs(l *logging.Instance, host string, options ...util.Option) (*Args, error)

NewArgs returns an instance of Args with the logging instance, host, and any provided args set. Users should *generally* not need to call this function as this is called during Transport creation (which is called by the Driver creation).

type File

type File struct {
	F string

	Writes [][]byte
	// contains filtered or unexported fields
}

File transport is a transport object that "connects" to a file rather than a device, it probably has no use outside of testing.

func NewFileTransport

func NewFileTransport() (*File, error)

NewFileTransport returns an instance of File transport. This is for testing purposes only.

func (*File) Close

func (t *File) Close() error

Close is a noop for the File transport.

func (*File) IsAlive

func (t *File) IsAlive() bool

IsAlive always returns true for File transport.

func (*File) Open

func (t *File) Open(a *Args) error

Open opens the File transport.

func (*File) Read

func (t *File) Read(_ int) ([]byte, error)

Read reads n bytes from the transport. File transport ignores EOF errors, see comment below.

func (*File) Write

func (t *File) Write(b []byte) error

Write writes bytes b to the transport.

type InChannelAuthData

type InChannelAuthData struct {
	Type                 string
	User                 string
	Password             string
	PrivateKeyPassPhrase string
}

InChannelAuthData is a struct containing all necessary information for the Channel to handle "in-channel" auth if necessary.

type SSHArgs

type SSHArgs struct {
	StrictKey            bool
	PrivateKeyPath       string
	PrivateKeyPassPhrase string
	ConfigFile           string
	KnownHostsFile       string
	NetconfConnection    bool
}

SSHArgs is a struct representing common transport SSH specific arguments.

func NewSSHArgs

func NewSSHArgs(options ...util.Option) (*SSHArgs, error)

NewSSHArgs returns an instance of SSH arguments with provided options set. Just like NewArgs, this should generally not be called by users directly.

type Standard

type Standard struct {
	SSHArgs *SSHArgs

	ExtraCiphers []string
	ExtraKexs    []string
	// contains filtered or unexported fields
}

Standard is the standard (crypto/ssh) transport object.

func NewStandardTransport

func NewStandardTransport(s *SSHArgs) (*Standard, error)

NewStandardTransport returns an instance of Standard transport.

func (*Standard) Close

func (t *Standard) Close() error

Close closes the Standard transport.

func (*Standard) IsAlive

func (t *Standard) IsAlive() bool

IsAlive returns true if the Standard transport session attribute is not nil.

func (*Standard) Open

func (t *Standard) Open(a *Args) error

Open opens the Standard transport.

func (*Standard) Read

func (t *Standard) Read(n int) ([]byte, error)

Read reads n bytes from the transport.

func (*Standard) Write

func (t *Standard) Write(b []byte) error

Write writes bytes b to the transport.

type System

type System struct {
	SSHArgs   *SSHArgs
	ExtraArgs []string
	OpenBin   string
	OpenArgs  []string
	// contains filtered or unexported fields
}

System is the default (/bin/ssh wrapper) transport object.

func NewSystemTransport

func NewSystemTransport(a *SSHArgs) (*System, error)

NewSystemTransport returns an instance of System transport.

func (*System) Close

func (t *System) Close() error

Close closes the System transport.

func (*System) IsAlive

func (t *System) IsAlive() bool

IsAlive returns true if the System transport file descriptor is not nil.

func (*System) Open

func (t *System) Open(a *Args) error

Open opens the System transport.

func (*System) Read

func (t *System) Read(n int) ([]byte, error)

Read reads n bytes from the transport.

func (*System) Write

func (t *System) Write(b []byte) error

Write writes bytes b to the transport.

type Telnet

type Telnet struct {
	TelnetArgs *TelnetArgs
	// contains filtered or unexported fields
}

Telnet is the telnet transport object.

func NewTelnetTransport

func NewTelnetTransport(a *TelnetArgs) (*Telnet, error)

NewTelnetTransport returns an instance of Telnet transport.

func (*Telnet) Close

func (t *Telnet) Close() error

Close closes the Telnet connection.

func (*Telnet) IsAlive

func (t *Telnet) IsAlive() bool

IsAlive returns true if the connection (c) attribute of the Telnet object is not nil.

func (*Telnet) Open

func (t *Telnet) Open(a *Args) error

Open opens the Telnet connection.

func (*Telnet) Read

func (t *Telnet) Read(n int) ([]byte, error)

Read reads n bytes from the transport.

func (*Telnet) Write

func (t *Telnet) Write(b []byte) error

Write writes bytes b to the transport.

type TelnetArgs

type TelnetArgs struct{}

TelnetArgs is a struct representing common transport Telnet specific arguments.

func NewTelnetArgs

func NewTelnetArgs(options ...util.Option) (*TelnetArgs, error)

NewTelnetArgs returns an instance of TelnetArgs with any provided options set. This should, just like the other NewXArgs functions, not be called directly by users.

type Transport

type Transport struct {
	Args *Args
	Impl transportImpl
	// contains filtered or unexported fields
}

Transport is a struct which wraps a transportImpl object and provides a unified interface to any type of transport selected by the user.

func NewTransport

func NewTransport(
	l *logging.Instance,
	host, transportType string,
	options ...util.Option,
) (*Transport, error)

NewTransport returns an instance of Transport with the requested transport implementation (as defined in transportType) set. Typically, users should not need to call this as the process of Driver creation will handle this for you.

func (*Transport) Close

func (t *Transport) Close(force bool) error

Close closes the underlying transportImpl transport object. force option is required for netconf as there will almost certainly always be a read in progress that we cannot stop and will block, therefore we need a way to bypass the lock.

func (*Transport) GetHost

func (t *Transport) GetHost() string

GetHost is a convenience method to return the Transport Args Host value.

func (*Transport) GetPort

func (t *Transport) GetPort() int

GetPort is a convenience method to return the Transport Args Port value.

func (*Transport) InChannelAuthData

func (t *Transport) InChannelAuthData() *InChannelAuthData

InChannelAuthData returns an instance of InChannelAuthData indicating if in-channel auth is supported, and if so, the necessary fields to accomplish that.

func (*Transport) IsAlive

func (t *Transport) IsAlive() bool

IsAlive returns true if the underlying transportImpl reports liveness, otherwise false.

func (*Transport) Open

func (t *Transport) Open() error

Open opens the underlying transportImpl transport object.

func (*Transport) Read

func (t *Transport) Read() ([]byte, error)

Read reads the Transport Args ReadSize bytes from the transportImpl.

func (*Transport) ReadN

func (t *Transport) ReadN(n int) ([]byte, error)

ReadN reads n bytes from the transportImpl.

func (*Transport) Write

func (t *Transport) Write(b []byte) error

Write writes bytes b to the transportImpl.

Jump to

Keyboard shortcuts

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