bird

package
v0.0.0-...-70eb549 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BirdVersion = 0
View Source
var IPVersion = "4"
View Source
var RateLimitConf struct {
	sync.RWMutex
	Conf RateLimitConfig
}
View Source
var RunQueue sync.Map // queue birdc commands before execution
View Source
var WorkerPoolSize = 8

WorkerPoolSize is the number of go routines used to parse routing tables concurrently

Functions

func ExpireCache

func ExpireCache() int

ExpireCache is a convenience method to expire the cache.

func GetCacheKey

func GetCacheKey(fname string, fargs ...interface{}) string

Determines the key in the cache, where the result of specific functions are stored. Eliminates the need to know what command was executed by that function.

func InitializeCache

func InitializeCache()

intitialize the Cache once during setup with either a MemoryCache or RedisCache implementation. TODO implement singleton pattern

func InstallRateLimitReset

func InstallRateLimitReset()

func IsSpecial

func IsSpecial(ret Parsed) bool

func Run

func Run(args string) (io.Reader, error)

Types

type BirdConfig

type BirdConfig struct {
	Listen         string
	ConfigFilename string `toml:"config"`
	BirdCmd        string `toml:"birdc"`
	CacheTtl       int    `toml:"ttl"`
}
var ClientConf BirdConfig

type Cache

type Cache interface {
	Set(key string, val Parsed, ttl int) error
	Get(key string) (Parsed, error)
	Expire() int
}

type CacheConfig

type CacheConfig struct {
	UseRedis      bool   `toml:"use_redis"`
	RedisServer   string `toml:"redis_server"`
	RedisPassword string `toml:"redis_password"`
	RedisDb       int    `toml:"redis_db"`

	MaxKeys int `toml:"max_keys"`
}
var CacheConf CacheConfig

type MemoryCache

type MemoryCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MemoryCache is a simple in-memory cache for parsed BIRD output. Limiting the number of cached results is using a simple LRU algorithm.

func NewMemoryCache

func NewMemoryCache(maxKeys int) *MemoryCache

NewMemoryCache creates a new MemoryCache with a maximum number of keys.

func (*MemoryCache) Expire

func (c *MemoryCache) Expire() int

Expire all keys in cache that are older than the TTL value.

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) (Parsed, error)

Get a key from the cache.

func (*MemoryCache) Set

func (c *MemoryCache) Set(key string, val Parsed, ttl int) error

Set a key in the cache.

type Parsed

type Parsed map[string]interface{}
var BirdError Parsed = Parsed{"error": "bird unreachable"}
var NilParse Parsed = (Parsed)(nil) // special Parsed values

func PipeRoutesFiltered

func PipeRoutesFiltered(useCache bool, pipe string, table string) (Parsed, bool)

func PipeRoutesFilteredCount

func PipeRoutesFilteredCount(useCache bool, pipe string, table string, neighborAddress string) (Parsed, bool)

func Protocols

func Protocols(useCache bool) (Parsed, bool)

func ProtocolsBgp

func ProtocolsBgp(useCache bool) (Parsed, bool)

func ProtocolsShort

func ProtocolsShort(useCache bool) (Parsed, bool)

func RoutesExport

func RoutesExport(useCache bool, protocol string) (Parsed, bool)

func RoutesExportCount

func RoutesExportCount(useCache bool, protocol string) (Parsed, bool)

func RoutesFiltered

func RoutesFiltered(useCache bool, protocol string) (Parsed, bool)

func RoutesLookupProtocol

func RoutesLookupProtocol(useCache bool, net string, protocol string) (Parsed, bool)

func RoutesLookupTable

func RoutesLookupTable(useCache bool, net string, table string) (Parsed, bool)

func RoutesNoExport

func RoutesNoExport(useCache bool, protocol string) (Parsed, bool)

func RoutesPeer

func RoutesPeer(useCache bool, peer string) (Parsed, bool)

func RoutesPrefixed

func RoutesPrefixed(useCache bool, prefix string) (Parsed, bool)

func RoutesProto

func RoutesProto(useCache bool, protocol string) (Parsed, bool)

func RoutesProtoCount

func RoutesProtoCount(useCache bool, protocol string) (Parsed, bool)

func RoutesProtoPrimaryCount

func RoutesProtoPrimaryCount(useCache bool, protocol string) (Parsed, bool)

func RoutesTable

func RoutesTable(useCache bool, table string) (Parsed, bool)

func RoutesTableAndPeer

func RoutesTableAndPeer(useCache bool, table string, peer string) (Parsed, bool)

func RoutesTableCount

func RoutesTableCount(useCache bool, table string) (Parsed, bool)

func RoutesTableFiltered

func RoutesTableFiltered(useCache bool, table string) (Parsed, bool)

func RunAndParse

func RunAndParse(useCache bool, key string, cmd string, parser func(io.Reader) Parsed, updateCache func(*Parsed)) (Parsed, bool)

func Status

func Status(useCache bool) (Parsed, bool)

func Symbols

func Symbols(useCache bool) (Parsed, bool)

type ParserConfig

type ParserConfig struct {
	FilterFields []string `toml:"filter_fields"`
}
var (
	ParserConf ParserConfig
)

type RateLimitConfig

type RateLimitConfig struct {
	Reqs    int
	Max     int `toml:"requests_per_minute"`
	Enabled bool
}

type RedisCache

type RedisCache struct {
	// contains filtered or unexported fields
}

func NewRedisCache

func NewRedisCache(config CacheConfig) (*RedisCache, error)

func (*RedisCache) Expire

func (self *RedisCache) Expire() int

func (*RedisCache) Get

func (self *RedisCache) Get(key string) (Parsed, error)

Get retrievs a birdwatcher `Parsed` result from the redis cache.

func (*RedisCache) Set

func (self *RedisCache) Set(key string, parsed Parsed, ttl int) error

Set adds a birdwatcher `Parsed` result to the redis cache.

type StatusConfig

type StatusConfig struct {
	ReconfigTimestampSource string `toml:"reconfig_timestamp_source"`
	ReconfigTimestampMatch  string `toml:"reconfig_timestamp_match"`

	FilterFields []string `toml:"filter_fields"`
}
var StatusConf StatusConfig

Jump to

Keyboard shortcuts

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