Documentation
¶
Index ¶
- func ClosePools()
- func GenerateSelfSignedPair() (*ecdsa.PrivateKey, []byte, error)
- func SSHExec(router *RouterConfig, cmd []string) ([]string, error)
- func SanitizeASPathRegex(aspath string) (string, error)
- func SanitizeBGPCommunity(asn, value int32) (string, error)
- func SanitizeBGPLargeCommunity(global, local1, local2 uint32) string
- func SanitizeBGPPeerName(name string) (string, error)
- func ValidateConfig(c *Config)
- func Version() string
- type BMPConfig
- type Config
- type GrpcConfig
- type HFBlock
- type HealthCheck
- type IPFamily
- type IPNet
- type Link
- type RedisConfig
- type Router
- type RouterConfig
- type RouterInstance
- func (rt *RouterInstance) BGPASPath(param string) ([]string, error)
- func (rt *RouterInstance) BGPCommunity(param string) ([]string, error)
- func (rt *RouterInstance) BGPLargeCommunity(param string) ([]string, error)
- func (rt *RouterInstance) BGPPeerRoutes(peerIP, peerName, queryType string) ([]string, error)
- func (rt *RouterInstance) BGPRoute(param *IPNet) ([]string, error)
- func (rt *RouterInstance) BGPSummary() ([]string, error)
- func (rt *RouterInstance) Healthcheck() error
- func (rt *RouterInstance) Ping(param *IPNet) ([]string, error)
- func (rt *RouterInstance) Traceroute(param *IPNet) ([]string, error)
- type RouterMap
- type SecurityTxtConfig
- type SentryConfig
- type TLSConfig
- type WebConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClosePools ¶
func ClosePools()
ClosePools closes all idle connections across all configured pools.
func GenerateSelfSignedPair ¶
func GenerateSelfSignedPair() (*ecdsa.PrivateKey, []byte, error)
GenerateSelfSignedPair mints an ephemeral ECDSA (P-256) key and a matching self-signed X.509 certificate (DER-encoded) for use by the HTTPS listener when no on-disk PKI material is configured.
func SSHExec ¶
func SSHExec(router *RouterConfig, cmd []string) ([]string, error)
SSHExec opens an SSH connection to the configured router and runs each command sequentially, returning the per-command stdout strings in order. Authentication methods offered: publickey (when SSHKey is set), password and keyboard-interactive (both when Password is set). Failures are returned as the coarse errs sentinels; detailed diagnostics are written to the server log.
func SanitizeASPathRegex ¶
SanitizeASPathRegex validates an AS-path regex and returns it with a leading "_" (or preserving an existing "^") and a trailing "_" or "$" anchor. Returns errs.ASPathEmpty, errs.ASPathTooLong, or errs.ASPathMalformed on invalid input.
func SanitizeBGPCommunity ¶
SanitizeBGPCommunity returns the canonical "ASN:VALUE" string for the RFC 1997 standard community (asn, value). Both fields must be in 0..65535. Returns errs.CommunityMalformed on any range failure.
func SanitizeBGPLargeCommunity ¶
SanitizeBGPLargeCommunity returns the canonical "GLOBAL:LOCAL1:LOCAL2" string for the RFC 8092 large community (global, local1, local2).
func SanitizeBGPPeerName ¶
SanitizeBGPPeerName validates a BGP peer/protocol name and returns it. Returns errs.PeerNameMalformed on failure.
func ValidateConfig ¶
func ValidateConfig(c *Config)
ValidateConfig normalises a freshly-parsed Config in place: drops devices without a Hostname and supplies loopback defaults for missing Source4/Source6.
func Version ¶
func Version() string
Version returns the process version string. For ldflags-tagged builds this is the bare value of [release], which is stable across replicas of the same build so the RPC cache namespace, HTTP ETag, and Sentry release roll-up agree cluster-wide. For untagged development builds (release == "untracked") a per-process nanos suffix is appended so the HTTP ETag still rotates across local restarts and the operator's browser picks up edits.
Types ¶
type BMPConfig ¶
type BMPConfig struct {
// Enabled toggles the BMP listener.
Enabled bool `yaml:"enabled"`
// Listen is the bind address in "host:port" form (e.g. ":11019").
Listen string `yaml:"listen"`
}
BMPConfig configures the stateless BGP Monitoring Protocol listener.
type Config ¶
type Config struct {
// Devices is the list of routers the server will expose.
Devices []RouterConfig `yaml:"devices"`
// Grpc controls the HTTP/2 listener.
Grpc GrpcConfig `yaml:"grpc"`
// Web controls the embedded WebUI.
Web WebConfig `yaml:"web"`
// SecurityTxt populates the /.well-known/security.txt endpoint.
SecurityTxt SecurityTxtConfig `yaml:"security.txt"`
// Redis configures the optional response cache.
Redis RedisConfig `yaml:"redis"`
// BMP configures the stateless BGP Monitoring Protocol collector.
Bmp BMPConfig `yaml:"bmp"`
// Logging controls the slog-based event stream.
Logging logging.Config `yaml:"logging"`
}
Config is the root structure parsed from config.yaml at startup.
func ParseConfigYaml ¶
ParseConfigYaml reads and unmarshals the configuration file at path and runs ValidateConfig.
type GrpcConfig ¶
type GrpcConfig struct {
// Enabled toggles the gRPC service mount.
Enabled bool `yaml:"enabled"`
// Listen is the bind address in "host:port" form.
Listen string `yaml:"listen"`
// TLS configures TLS termination.
TLS TLSConfig `yaml:"tls"`
}
GrpcConfig controls the gRPC listener.
type HFBlock ¶
type HFBlock struct {
// Text is the plain-text label.
Text string `yaml:"text"`
// Logo is a URL to a logo image.
Logo string `yaml:"logo"`
// Links is the ordered list of branded links.
Links []Link `yaml:"links"`
}
HFBlock describes a header or footer content block.
func (*HFBlock) LinksString ¶
LinksString serialises the link list to "name|href,name|href" form.
type HealthCheck ¶
type HealthCheck struct {
// Checked is the timestamp of the last completed probe attempt.
Checked time.Time
// Healthy reports whether the last probe completed without an SSH error.
Healthy bool
}
HealthCheck records the outcome of the most recent reachability probe.
type IPFamily ¶
type IPFamily string
IPFamily enumerates the IP address families supported by the router templates.
type IPNet ¶
type IPNet struct {
// IP is the host portion in canonical (un-bracketed) form.
IP string
// CIDR is the prefix-length portion (without the leading "/").
CIDR string
// Family is the detected address family.
Family IPFamily
}
IPNet is the validated, parsed representation of an IP address or CIDR prefix.
func NewIPNET ¶
NewIPNET parses a textual IP address or CIDR prefix into an IPNet. Returns errs.IPInvalid or errs.NetInvalid for malformed input.
func NewIPNetFromProtobuf ¶
NewIPNetFromProtobuf parses target as a literal IP/CIDR or, failing that, resolves it as a hostname via DNS and returns the first address.
func (*IPNet) FamilyString ¶
FamilyString returns the family as its string form ("ipv4" or "ipv6").
func (*IPNet) ToIPNet ¶
ToIPNet returns the address as a standard-library *net.IPNet.
type Link ¶
type Link struct {
// Text is the visible link label.
Text string `yaml:"text"`
// URL is the link target.
URL string `yaml:"url"`
}
Link is one entry in an HFBlock's link list.
type RedisConfig ¶
type RedisConfig struct {
// Enabled toggles the cache middleware.
Enabled bool `yaml:"enabled"`
// URI is a redis:// or rediss:// URL.
URI string `yaml:"uri"`
// TTL is a time.ParseDuration string controlling cache lifetime.
TTL string `yaml:"ttl"`
}
RedisConfig configures the optional shared response cache.
type Router ¶
type Router interface {
// Ping returns the command sequence that probes reachability.
Ping(*RouterConfig, *IPNet) ([]string, error)
// Traceroute returns the command sequence that records hops to the target.
Traceroute(*RouterConfig, *IPNet) ([]string, error)
// BGPSummary returns the command sequence for the BGP neighbour summary.
BGPSummary(*RouterConfig) ([]string, error)
// BGPRoute returns the command sequence for a BGP-path lookup by prefix.
BGPRoute(*RouterConfig, *IPNet) ([]string, error)
// BGPCommunity returns the command sequence for a standard-community lookup.
BGPCommunity(*RouterConfig, string) ([]string, error)
// BGPLargeCommunity returns the command sequence for an RFC 8092 large-community lookup.
BGPLargeCommunity(*RouterConfig, string) ([]string, error)
// BGPASPath returns the command sequence for an AS-path regex lookup.
BGPASPath(*RouterConfig, string) ([]string, error)
// BGPPeerRoutes returns the command sequence for peer session route lookups.
BGPPeerRoutes(*RouterConfig, string, string, string) ([]string, error)
}
Router is the contract every vendor template implements: it returns the command sequence for each supported diagnostic operation.
type RouterConfig ¶
type RouterConfig struct {
// Name is the human-readable identifier shown in the UI.
Name string `yaml:"name"`
// Hostname is the SSH target ("host" or "host:port").
Hostname string `yaml:"hostname"`
// Username is the SSH login.
Username string `yaml:"username"`
// Password is the SSH password. Ignored when SSHKey is set.
Password string `yaml:"password"`
// SSHKey is the path to a private key on the server filesystem.
SSHKey string `yaml:"ssh_key"`
// VRF is the routing instance interpolated into vendor templates.
VRF string `yaml:"vrf"`
// Location is the free-form site label.
Location string `yaml:"location"`
// Source4 is the IPv4 source address bound to ping/traceroute.
Source4 *IPNet `yaml:"source4"`
// Source6 is the IPv6 source address bound to ping/traceroute.
Source6 *IPNet `yaml:"source6"`
// Type is the registered router-template name.
Type string `yaml:"type"`
// SSHPoolSize is the maximum number of idle SSH connections kept in the pool for this device.
SSHPoolSize int `yaml:"ssh_pool_size"`
}
RouterConfig describes a single managed device.
func (*RouterConfig) HasSSHCredentials ¶
func (rc *RouterConfig) HasSSHCredentials() bool
HasSSHCredentials reports whether the router config has username configured.
type RouterInstance ¶
type RouterInstance struct {
// Router is the vendor-specific template for this device.
Router Router
// Config holds the connection parameters for this device.
Config *RouterConfig
// HealthCheck stores the latest reachability state.
HealthCheck *HealthCheck
}
RouterInstance binds a Router implementation to its per-device RouterConfig and a shared HealthCheck record.
func (*RouterInstance) BGPASPath ¶
func (rt *RouterInstance) BGPASPath(param string) ([]string, error)
BGPASPath renders and executes the AS-path regex lookup command sequence.
func (*RouterInstance) BGPCommunity ¶
func (rt *RouterInstance) BGPCommunity(param string) ([]string, error)
BGPCommunity renders and executes the standard-community lookup command sequence.
func (*RouterInstance) BGPLargeCommunity ¶
func (rt *RouterInstance) BGPLargeCommunity(param string) ([]string, error)
BGPLargeCommunity renders and executes the large-community lookup command sequence.
func (*RouterInstance) BGPPeerRoutes ¶
func (rt *RouterInstance) BGPPeerRoutes(peerIP, peerName, queryType string) ([]string, error)
BGPPeerRoutes renders and executes the peer session route lookup command sequence.
func (*RouterInstance) BGPRoute ¶
func (rt *RouterInstance) BGPRoute(param *IPNet) ([]string, error)
BGPRoute renders and executes the BGP-route lookup command sequence.
func (*RouterInstance) BGPSummary ¶
func (rt *RouterInstance) BGPSummary() ([]string, error)
BGPSummary renders and executes the neighbour-summary command sequence.
func (*RouterInstance) Healthcheck ¶
func (rt *RouterInstance) Healthcheck() error
Healthcheck runs a no-op SSH session against the router and updates the HealthCheck record with the timestamp and outcome.
func (*RouterInstance) Ping ¶
func (rt *RouterInstance) Ping(param *IPNet) ([]string, error)
Ping renders and executes the ping command sequence for this router.
func (*RouterInstance) Traceroute ¶
func (rt *RouterInstance) Traceroute(param *IPNet) ([]string, error)
Traceroute renders and executes the traceroute command sequence.
type RouterMap ¶
type RouterMap []*RouterInstance
RouterMap is the in-memory catalogue of every configured router.
type SecurityTxtConfig ¶
type SecurityTxtConfig struct {
// Enabled toggles the /.well-known/security.txt handler.
Enabled bool `yaml:"enabled"`
// Contact is one or more contact URIs.
Contact string `yaml:"contact"`
// Canonical is the canonical URL where this security.txt lives.
Canonical string `yaml:"canonical"`
// Encryption is a URL pointing to a PGP/OpenPGP key.
Encryption string `yaml:"encryption"`
// Acknowledgements is a URL listing security-researcher credits.
Acknowledgements string `yaml:"acknowledgements"`
// PreferredLanguages is a comma-separated list of RFC 5646 tags.
PreferredLanguages string `yaml:"preferred-languages"`
// Policy is a URL to the organisation's vulnerability policy.
Policy string `yaml:"policy"`
// Hiring is a URL to a security-jobs page.
Hiring string `yaml:"hiring"`
// CSAF is a URL to a CSAF provider-metadata document.
CSAF string `yaml:"csaf"`
// Expires is the RFC 3339 expiration timestamp; empty synthesises one year from now.
Expires string `yaml:"expires"`
}
SecurityTxtConfig holds the fields exposed via /.well-known/security.txt.
func (*SecurityTxtConfig) String ¶
func (s *SecurityTxtConfig) String() string
String renders the config as an RFC 9116 security.txt document.
type SentryConfig ¶
type SentryConfig struct {
// Enabled toggles both server-side capture and the WebUI flag.
Enabled bool `yaml:"enabled"`
// DSN is the Sentry project DSN.
DSN string `yaml:"dsn"`
// Environment is a free-form tag attached to every event.
Environment string `yaml:"environment"`
// SampleRate is the traces-sample-rate in [0, 1].
SampleRate float64 `yaml:"sample_rate"`
}
SentryConfig describes the optional Sentry SDK configuration.
type TLSConfig ¶
type TLSConfig struct {
// Enabled toggles TLS.
Enabled bool `yaml:"enabled"`
// Cert is the path to a PEM-encoded certificate chain.
Cert string `yaml:"cert"`
// Key is the path to a PEM-encoded private key.
Key string `yaml:"key"`
// SelfSigned causes the server to generate a fresh in-memory certificate at startup.
SelfSigned bool `yaml:"self_signed"`
}
TLSConfig configures TLS termination.
type WebConfig ¶
type WebConfig struct {
// Enabled toggles serving of the embedded WebUI bundle.
Enabled bool `yaml:"enabled"`
// GrpcURL is the gRPC-Web endpoint the WebUI dials.
GrpcURL string `yaml:"grpc_url"`
// Title is the document title shown in the browser tab.
Title string `yaml:"title"`
// Header populates the top-of-page brand block.
Header HFBlock `yaml:"header"`
Footer HFBlock `yaml:"footer"`
// Sentry configures the optional browser-side Sentry SDK.
Sentry SentryConfig `yaml:"sentry"`
}
WebConfig controls the embedded WebUI.