netrasp

package
v0.0.0-...-4b0d55c Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package netrasp provides an easy way to communicate with network devices

Using an SSH connection it lets you send commands and configure devices that only supports screen scraping.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigCommand

type ConfigCommand struct {
	// The command that was sent to the device
	Command string
	// The output seen after entering the command
	Output string
}

ConfigCommand contains a configuration command together with the output from that command.

type ConfigOpt

type ConfigOpt interface {
	// contains filtered or unexported methods
}

ConfigOpt configures a Netrasp connection and platform.

func WithDialTimeout

func WithDialTimeout(t time.Duration) ConfigOpt

WithDialTimeout allows you to configure timeout for dialing SSH server.

func WithDriver

func WithDriver(name string) ConfigOpt

WithDriver tells Netrasp which network driver to use for the connection for example "asa", "ios", "nxos".

func WithInsecureIgnoreHostKey

func WithInsecureIgnoreHostKey() ConfigOpt

WithInsecureIgnoreHostKey allows you to ignore the validation of the public SSH key of a device against a reference in a known_hosts file. Using this option should be considered a security risk.

func WithSSHCipher

func WithSSHCipher(name string) ConfigOpt

WithSSHCipher allows you to configure additional SSH Ciphers that the connection will use. The parameter can be useful if your device doesn't support the default ciphers.

func WithSSHKeyExchange

func WithSSHKeyExchange(name string) ConfigOpt

WithSSHKeyExchange allows you to configure additional SSH key exchange algorithms. The parameter can be useful if your device doesn't support the default algorithms.

func WithSSHPort

func WithSSHPort(port int) ConfigOpt

WithSSHPort allows you to specify an alternate SSH port, defaults to 22.

func WithUsernamePassword

func WithUsernamePassword(username string, password string) ConfigOpt

type ConfigResult

type ConfigResult struct {
	ConfigCommands []ConfigCommand
}

ConfigResult is returned by a Configure operation and contains output and results.

type Platform

type Platform interface {
	// Disconnect from a device
	Close(context.Context) error
	// Configure device with the provided commands
	Configure(context.Context, []string) (ConfigResult, error)
	// Open a connection to a device
	Dial(context.Context) error
	// Elevate privileges on device
	Enable(context.Context) error
	// Run a command against a device
	Run(context.Context, string) (string, error)
	// Run a command against a device and search for a specific prompt
	RunUntil(context.Context, string, *regexp.Regexp) (string, error)
}

Platform defines an interface for network drivers.

func New

func New(hostname string, opts ...ConfigOpt) (Platform, error)

New creates a new SSH connection to the device.

Jump to

Keyboard shortcuts

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