device

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

Variables

This section is empty.

Functions

func AllCiphers added in v0.2.0

func AllCiphers() []string

func AllHostKeyAlgorithms added in v0.2.0

func AllHostKeyAlgorithms() []string

func AllKeyExchanges added in v0.2.0

func AllKeyExchanges() []string

func UsernamePasswordConfig added in v0.2.0

func UsernamePasswordConfig(username, password string) *ssh.ClientConfig

Types

type Connection added in v0.2.0

type Connection interface {
	Start(ctx context.Context) error
	Stop() error
	Send(data []byte) error
	ReadUntilFunc(ctx context.Context, timeout time.Duration, f InputCondition) ([]byte, error)
}

Connection is the low-level I/O interface for a device session.

func NewConnection added in v0.2.0

func NewConnection(stdin io.WriteCloser, stdout io.Reader) Connection

NewConnection creates a Connection from an SSH stdin/stdout pair.

func NewSSHConnection added in v0.2.0

func NewSSHConnection(host string, port uint16, config *ssh.ClientConfig) (Connection, func(), error)

NewSSHConnection dials an SSH session and returns a DeviceConnection plus a done() function that closes the session and client when called.

type Device

type Device interface {
	Initialize(ctx context.Context) error
	DisablePaging(ctx context.Context) error
	Cmd(ctx context.Context, timeout time.Duration, command string) (*Result, error)
}

Device is the minimal interface for interacting with a network switch.

type InputCondition added in v0.2.0

type InputCondition func([]byte) bool

InputCondition returns true when the accumulated output satisfies a completion criterion.

type Result

type Result struct {
	Command string
	Output  string
	Failed  bool
	FailMsg string
}

Result is the output of a single command execution.

type Settings added in v0.2.0

type Settings struct {
	DriverName     string
	Connection     Connection
	Timeout        time.Duration // default command timeout; 0 uses DefaultTimeout
	EnablePassword *string       // nil means no enable password is required
}

Settings holds the connection and timing configuration shared by all drivers.

Jump to

Keyboard shortcuts

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