corerad

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package corerad implements package main logic for the CoreRAD server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Signals added in v0.2.8

func Signals() []os.Signal

Signals returns a list of signals which can interrupt this program.

Types

type Advertiser

type Advertiser struct {
	// OnInconsistentRA is an optional hook that fires when a router advertisement
	// is received that is inconsistent with the configuration being served by
	// this Advertiser, resulting in potential problems for clients. ours is
	// the RA generated by this Advertiser, and theirs is the RA received from
	// a remote router. If OnInconsistentRA is nil, the hook is not fired.
	OnInconsistentRA func(ours, theirs *ndp.RouterAdvertisement)
	// contains filtered or unexported fields
}

An Advertiser sends NDP router advertisements.

func NewAdvertiser

func NewAdvertiser(
	cctx *Context,
	cfg config.Interface,
	dialer *system.Dialer,
	watchC <-chan netstate.Change,
	terminate func() bool,
) *Advertiser

NewAdvertiser creates an Advertiser for the specified interface. If ll is nil, logs are discarded. If mm is nil, metrics are discarded.

func (*Advertiser) Ready added in v0.2.7

func (a *Advertiser) Ready() <-chan struct{}

Ready implements Task.

func (*Advertiser) Run added in v0.2.7

func (a *Advertiser) Run(ctx context.Context) error

Run initializes the configured interface and begins router solicitation and advertisement handling. Run will block until ctx is canceled or an error occurs.

func (*Advertiser) String added in v0.2.7

func (a *Advertiser) String() string

String implements Task.

type Context added in v0.2.8

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

A Context carries application context and telemetry throughout the Server and its Tasks.

func NewContext added in v0.2.8

func NewContext(ll *log.Logger, mm *Metrics, state system.State) *Context

NewContext produces a Context for use with a Server. If any of the inputs are nil, a no-op implementation will be used.

type Metrics added in v0.2.3

type Metrics struct {
	// General server metrics.
	Info metricslite.Gauge
	Time metricslite.Gauge

	// Shared per-advertiser/monitor metrics.
	MessagesReceivedInvalidTotal metricslite.Counter

	// Per-advertiser metrics.
	AdvLastMulticastTime                       metricslite.Gauge
	AdvMessagesReceivedTotal                   metricslite.Counter
	AdvRouterAdvertisementInconsistenciesTotal metricslite.Counter
	AdvRouterAdvertisementsTotal               metricslite.Counter
	AdvErrorsTotal                             metricslite.Counter

	// Per-monitor metrics.
	MonMessagesReceivedTotal                 metricslite.Counter
	MonFlagManaged                           metricslite.Gauge
	MonFlagOther                             metricslite.Gauge
	MonDefaultRouteExpirationTime            metricslite.Gauge
	MonPrefixAutonomous                      metricslite.Gauge
	MonPrefixOnLink                          metricslite.Gauge
	MonPrefixPreferredLifetimeExpirationTime metricslite.Gauge
	MonPrefixValidLifetimeExpirationTime     metricslite.Gauge
	// contains filtered or unexported fields
}

Metrics contains metrics for a CoreRAD instance.

func NewMetrics added in v0.2.3

func NewMetrics(
	m metricslite.Interface,
	version string,
	buildTime time.Time,
	state system.State,
	ifis []config.Interface,
) *Metrics

NewMetrics produces a Metrics structure which will register its metrics to the specified metricslite.Interface. If m is nil, metrics are discarded.

func (*Metrics) Series added in v0.2.4

func (m *Metrics) Series() (map[string]metricslite.Series, bool)

Series produces a set of output timeseries from the Metrics, assuming the Metrics were initialized with a compatible metricslite.Interface. If not, Series will return nil, false.

type Monitor added in v0.2.6

type Monitor struct {
	// OnMessage is an optional callback which will fire when the monitor
	// receives an NDP message.
	OnMessage func(m ndp.Message)
	// contains filtered or unexported fields
}

A Monitor listens and reports on NDP traffic.

func NewMonitor added in v0.2.6

func NewMonitor(
	cctx *Context,
	iface string,
	dialer *system.Dialer,
	watchC <-chan netstate.Change,
	verbose bool,
) *Monitor

NewMonitor creates a Monitor for the specified interface. If ll is nil, logs are discarded. If mm is nil, metrics are discarded.

func (*Monitor) Ready added in v0.2.7

func (m *Monitor) Ready() <-chan struct{}

Ready implements Task.

func (*Monitor) Run added in v0.2.7

func (m *Monitor) Run(ctx context.Context) error

Run initializes the configured interface and listening and reporting on incoming NDP traffic. Run will block until ctx is canceled or an error occurs.

func (*Monitor) String added in v0.2.7

func (m *Monitor) String() string

String implements Task.

type Server

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

A Server coordinates the goroutines that handle various pieces of the CoreRAD server.

func NewServer

func NewServer(cctx *Context) *Server

NewServer creates a Server with the input configuration and logger. If ll is nil, logs are discarded.

func (*Server) BuildTasks added in v0.2.7

func (s *Server) BuildTasks(cfg config.Config, debug http.Handler) []Task

BuildTasks produces Tasks for the Server to run from the input configuration and termination check function. terminate reports whether the process should expect to be terminated and stopped or immediately reloaded by a supervision daemon.

func (*Server) Serve added in v0.2.7

func (s *Server) Serve(sigC chan os.Signal, n *sdnotify.Notifier, tasks []Task) error

Serve starts the CoreRAD server and runs Tasks until a signal is received, indicating a shutdown.

type Task added in v0.2.7

type Task interface {
	// Run runs the Task until ctx is canceled or an error occurs. If ctx is
	// canceled, the Task should consume that error internally and return nil.
	Run(ctx context.Context) error

	// Ready indicates if a Task has been fully initialized once.
	Ready() <-chan struct{}

	// String returns information about a Task.
	fmt.Stringer
}

A Task is a Server-owned task which will run until the input context is canceled.

Jump to

Keyboard shortcuts

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