driver

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package driver holds the per-vendor network-device CLI knowledge: how to classify a command (the structural read-only seal), how to disable paging, what the prompt looks like, and what error output looks like. One driver covers one vendor OS family; in-family version differences live in the pattern tables, not in new drivers (NETDEV_SPEC §4).

Index

Constants

View Source
const ShellMetachars = ";|&`$()<>\\"

ShellMetachars is the refusal set: pipe/command substitution/sequencing/ redirection/subshell syntax. Exec explains the rule when it fires.

Variables

This section is empty.

Functions

func ExtraRead

func ExtraRead(driverKey string) []string

ExtraRead returns the current runtime extensions (for settings UI).

func IsShellMetacharDriver

func IsShellMetacharDriver(key string) bool

IsShellMetacharDriver reports whether a driver key runs a general shell and therefore rejects metacharacters in commands.

func Keys

func Keys() []string

Keys lists registered driver keys (sorted; for error messages and UI).

func SetExtraRead

func SetExtraRead(driverKey string, prefixes []string)

SetExtraRead prefixes replaces the runtime read extensions for one driver. Prefixes are normalized (lowercased, whitespace-collapsed) and matched with the same word-boundary rule as the built-in tables.

Types

type Class

type Class int

Class is a command's safety classification. The exec tool refuses anything that is not Read — Write and Dangerous are proposal material (P4), Unknown defaults to the conservative Write handling per the spec's Appendix B-1.

const (
	Read Class = iota
	Write
	Dangerous
	Unknown
)

func (Class) String

func (c Class) String() string

type Driver

type Driver interface {
	// Key identifies the driver, e.g. "huawei-vrp", "cisco-ios".
	Key() string
	// Classify categorizes one CLI command line (first line, no newline).
	Classify(cmd string) Class
	// PagingOff returns the command(s) to run once at session start so long
	// outputs are not interactively paged.
	PagingOff() []string
	// Prompt matches the device prompt as it appears at the end of output
	// (user view, config view, etc.). The session engine anchors it to the
	// final line.
	Prompt() *regexp.Regexp
	// Errors matches a single output line that indicates the command failed.
	Errors() []*regexp.Regexp
}

Driver describes one vendor OS CLI.

func For

func For(vendor, os string) (Driver, bool)

For resolves vendor+os to a driver. OS is matched leniently: "vrp8" and "vrp5" both map to the huawei-vrp driver (quirk tables are internal).

Jump to

Keyboard shortcuts

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