utils

package
v0.0.0-...-15986b7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSelfSignedPair

func GenerateSelfSignedPair() (*ecdsa.PrivateKey, []byte, error)

func SSHExec

func SSHExec(router *RouterConfig, cmd []string) ([]string, error)

func SanitizeASPathRegex

func SanitizeASPathRegex(aspath string) (string, error)

func ValidateConfig

func ValidateConfig(c *Config)

func Version

func Version() string

Types

type Config

type Config struct {
	Devices     []RouterConfig    `yaml:"devices"`
	Grpc        GrpcConfig        `yaml:"grpc"`
	Web         WebConfig         `yaml:"web"`
	SecurityTxt SecurityTxtConfig `yaml:"security.txt"`
	Redis       RedisConfig       `yaml:"redis"`
}

func ParseConfigYaml

func ParseConfigYaml(path string) (*Config, error)

type GrpcConfig

type GrpcConfig struct {
	Enabled bool      `yaml:"enabled"`
	Listen  string    `yaml:"listen"`
	TLS     TLSConfig `yaml:"tls"`
}

type HFBlock

type HFBlock struct {
	Text  string `yaml:"text"`
	Links []Link `yaml:"links"`
}

func (*HFBlock) LinksString

func (hf *HFBlock) LinksString() string

type HealthCheck

type HealthCheck struct {
	Checked time.Time
	Healthy bool
}

type IPFamily

type IPFamily string
const (
	IPv4 IPFamily = "ipv4"
	IPv6 IPFamily = "ipv6"
)

type IPNet

type IPNet struct {
	IP     string
	CIDR   string
	Family IPFamily
}

func NewIPNET

func NewIPNET(ip string) (*IPNet, error)

func NewIPNetFromProtobuf

func NewIPNetFromProtobuf(target string) (*IPNet, error)

func (*IPNet) FamilyString

func (ip *IPNet) FamilyString() string

func (*IPNet) IsIPv4

func (ip *IPNet) IsIPv4() bool

func (*IPNet) IsIPv6

func (ip *IPNet) IsIPv6() bool

func (*IPNet) String

func (ip *IPNet) String() string

func (*IPNet) ToIP

func (ip *IPNet) ToIP() net.IP

func (*IPNet) ToIPNet

func (ip *IPNet) ToIPNet() *net.IPNet

func (*IPNet) UnmarshalYAML

func (ip *IPNet) UnmarshalYAML(unmarshal func(interface{}) error) error
type Link struct {
	Text string `yaml:"text"`
	URL  string `yaml:"url"`
}

type RedisConfig

type RedisConfig struct {
	Enabled bool   `yaml:"enabled"`
	URI     string `yaml:"uri"`
	TTL     string `yaml:"ttl"`
}

type Router

type Router interface {
	Ping(*RouterConfig, *IPNet) ([]string, error)
	Traceroute(*RouterConfig, *IPNet) ([]string, error)
	BGPRoute(*RouterConfig, *IPNet) ([]string, error)
	BGPCommunity(*RouterConfig, string) ([]string, error)
	BGPASPath(*RouterConfig, string) ([]string, error)
}

type RouterConfig

type RouterConfig struct {
	Name     string `yaml:"name"`
	Hostname string `yaml:"hostname"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	SSHKey   string `yaml:"ssh_key"`
	VRF      string `yaml:"vrf"`
	Location string `yaml:"location"`
	Source4  *IPNet `yaml:"source4"`
	Source6  *IPNet `yaml:"source6"`
	Type     string `yaml:"type"`
}

type RouterInstance

type RouterInstance struct {
	Router      Router
	Config      *RouterConfig
	HealthCheck *HealthCheck
}

func (*RouterInstance) BGPASPath

func (rt *RouterInstance) BGPASPath(param string) ([]string, error)

func (*RouterInstance) BGPCommunity

func (rt *RouterInstance) BGPCommunity(param string) ([]string, error)

func (*RouterInstance) BGPRoute

func (rt *RouterInstance) BGPRoute(param *IPNet) ([]string, error)

func (*RouterInstance) Healthcheck

func (rt *RouterInstance) Healthcheck() error

func (*RouterInstance) Ping

func (rt *RouterInstance) Ping(param *IPNet) ([]string, error)

func (*RouterInstance) Traceroute

func (rt *RouterInstance) Traceroute(param *IPNet) ([]string, error)

type RouterMap

type RouterMap []*RouterInstance

func (RouterMap) Get

func (rm RouterMap) Get(name string) (*RouterInstance, bool)

func (RouterMap) GetByID

func (rm RouterMap) GetByID(id int64) (*RouterInstance, bool)

type SecurityTxtConfig

type SecurityTxtConfig struct {
	Enabled            bool   `yaml:"enabled"`
	Contact            string `yaml:"contact"`
	Canonical          string `yaml:"canonical"`
	Encryption         string `yaml:"encryption"`
	Acknowledgements   string `yaml:"acknowledgements"`
	PreferredLanguages string `yaml:"preferred-languages"`
	Policy             string `yaml:"policy"`
	Hiring             string `yaml:"hiring"`
	CSAF               string `yaml:"csaf"`
	Expires            string `yaml:"expires"`
}

func (*SecurityTxtConfig) String

func (s *SecurityTxtConfig) String() string

type SentryConfig

type SentryConfig struct {
	Enabled     bool    `yaml:"enabled"`
	DSN         string  `yaml:"dsn"`
	Environment string  `yaml:"environment"`
	SampleRate  float64 `yaml:"sample_rate"`
}

type TLSConfig

type TLSConfig struct {
	Enabled    bool   `yaml:"enabled"`
	Cert       string `yaml:"cert"`
	Key        string `yaml:"key"`
	SelfSigned bool   `yaml:"self_signed"`
}

type WebConfig

type WebConfig struct {
	Enabled   bool         `yaml:"enabled"`
	GrpcURL   string       `yaml:"grpc_url"`
	Theme     string       `yaml:"theme"`
	Title     string       `yaml:"title"`
	Header    HFBlock      `yaml:"header"`
	Footer    HFBlock      `yaml:"footer"`
	RtListMax int          `yaml:"rt_list_max"`
	Sentry    SentryConfig `yaml:"sentry"`
}

Jump to

Keyboard shortcuts

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