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 ¶
- type ConfigCommand
- type ConfigOpt
- func WithDialTimeout(t time.Duration) ConfigOpt
- func WithDriver(name string) ConfigOpt
- func WithInsecureIgnoreHostKey() ConfigOpt
- func WithSSHCipher(name string) ConfigOpt
- func WithSSHKeyExchange(name string) ConfigOpt
- func WithSSHPort(port int) ConfigOpt
- func WithUsernamePassword(username string, password string) ConfigOpt
- func WithUsernamePasswordEnableSecret(username string, password string, enableSecret string) ConfigOpt
- type ConfigResult
- type Platform
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 ¶
WithDialTimeout allows you to configure timeout for dialing SSH server.
func WithDriver ¶
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 ¶
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 ¶
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 ¶
WithSSHPort allows you to specify an alternate SSH port, defaults to 22.
func WithUsernamePassword ¶
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.