Documentation ¶
Index ¶
- Constants
- func GetNetconfTransportNames() []string
- func GetTransportNames() []string
- type Args
- type File
- type Implementation
- type InChannelAuthData
- type InChannelAuthImplementation
- type InChannelAuthType
- type SSHArgs
- type SSHImplementation
- type Standard
- type System
- type Telnet
- type TelnetArgs
- type Transport
- func (t *Transport) Close(force bool) error
- func (t *Transport) GetHost() string
- func (t *Transport) GetPort() int
- func (t *Transport) InChannelAuthData() *InChannelAuthData
- func (t *Transport) IsAlive() bool
- func (t *Transport) Open() error
- func (t *Transport) Read() ([]byte, error)
- func (t *Transport) ReadN(n int) ([]byte, error)
- func (t *Transport) Write(b []byte) error
Constants ¶
const ( // DefaultTransport is the default transport constant for scrapligo, this defaults to the // "system" transport. DefaultTransport = "system" )
const (
// FileTransport transport name.
FileTransport = "file"
)
const (
// StandardTransport is the standard (crypto/ssh) transport for scrapligo.
StandardTransport = "standard"
)
const (
// SystemTransport is the default "system" (/bin/ssh wrapper) transport for scrapligo.
SystemTransport = "system"
)
const (
// TelnetTransport is the telnet transport for scrapligo.
TelnetTransport = "telnet"
)
Variables ¶
This section is empty.
Functions ¶
func GetNetconfTransportNames ¶ added in v1.0.0
func GetNetconfTransportNames() []string
GetNetconfTransportNames returns a slice of available NETCONF transport type names.
func GetTransportNames ¶ added in v1.0.0
func GetTransportNames() []string
GetTransportNames is returns a slice of available transport type names.
Types ¶
type Args ¶ added in v1.0.0
type Args struct { UserImplementation Implementation 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.
type File ¶ added in v1.0.0
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 ¶ added in v1.0.0
NewFileTransport returns an instance of File transport. This is for testing purposes only.
type Implementation ¶
type Implementation interface { Open(a *Args) error Close() error IsAlive() bool Read(n int) ([]byte, error) Write(b []byte) error }
Implementation defines a valid base scrapligo transport -- for SSH-specific transports users should satisfy SSHImplementation -- and for transports that require authentication "in channel" users should satisfy InChannelAuthImplementation (this could be in addition to the SSH one!).
type InChannelAuthData ¶ added in v1.0.3
type InChannelAuthData struct { Type InChannelAuthType 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 InChannelAuthImplementation ¶ added in v1.3.0
type InChannelAuthImplementation interface { Implementation GetInChannelAuthType() InChannelAuthType }
InChannelAuthImplementation is an interface that when satisfied tells us that the transport wants to do "in channel" authentication -- meaning actually look for user/password prompt and send those values in the connection rather than in the protocol/out of band.
type InChannelAuthType ¶ added in v1.3.0
type InChannelAuthType string
InChannelAuthType is an enum-ish string that represents valid in channel auth flavors.
const ( // InChannelAuthUnsupported indicates that the transport does *not* support in channel auth. InChannelAuthUnsupported InChannelAuthType = "unsupported" // InChannelAuthSSH indicates that the transport supports in channel ssh auth. InChannelAuthSSH InChannelAuthType = "ssh" // InChannelAuthTelnet indicates that the transport supports in channel telnet auth. InChannelAuthTelnet InChannelAuthType = "telnet" )
type SSHArgs ¶ added in v1.0.0
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.
type SSHImplementation ¶ added in v1.3.0
type SSHImplementation interface { Implementation GetSSHArgs() *SSHArgs }
SSHImplementation is an interface that SSH transports *may* implement, this is currently only required if the SSH transport also requires (or just supports) "in-channel" ssh authentication.
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 ¶ added in v1.0.0
NewStandardTransport returns an instance of Standard transport.
func (*Standard) IsAlive ¶
IsAlive returns true if the Standard transport session attribute is not nil.
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 ¶ added in v1.0.0
NewSystemTransport returns an instance of System transport.
func (*System) GetInChannelAuthType ¶ added in v1.3.0
func (t *System) GetInChannelAuthType() InChannelAuthType
GetInChannelAuthType returns the in channel auth flavor for the system transport.
func (*System) GetSSHArgs ¶ added in v1.3.0
GetSSHArgs returns the ssh args for the system transport.
type Telnet ¶
type Telnet struct { TelnetArgs *TelnetArgs // contains filtered or unexported fields }
Telnet is the telnet transport object.
func NewTelnetTransport ¶ added in v1.0.0
func NewTelnetTransport(a *TelnetArgs) (*Telnet, error)
NewTelnetTransport returns an instance of Telnet transport.
func (*Telnet) GetInChannelAuthType ¶ added in v1.3.0
func (t *Telnet) GetInChannelAuthType() InChannelAuthType
GetInChannelAuthType returns the in channel auth flavor for the telnet transport.
func (*Telnet) IsAlive ¶
IsAlive returns true if the connection (c) attribute of the Telnet object is not nil.
type TelnetArgs ¶ added in v1.0.0
type TelnetArgs struct{}
TelnetArgs is a struct representing common transport Telnet specific arguments.
func NewTelnetArgs ¶ added in v1.0.0
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 Implementation // 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 ¶ added in v1.0.0
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 ¶
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 ¶ added in v1.0.0
GetHost is a convenience method to return the Transport Args Host value.
func (*Transport) GetPort ¶ added in v1.0.0
GetPort is a convenience method to return the Transport Args Port value.
func (*Transport) InChannelAuthData ¶ added in v1.0.3
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 ¶
IsAlive returns true if the underlying transportImpl reports liveness, otherwise false.