routes

package
v0.0.0-...-851e5e8 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package routes provides route setting functionality.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRouteToOtherDestinationExists defines that route for specified network already exists but not to a specified destination
	ErrRouteToOtherDestinationExists = fmt.Errorf("route to differ")
)

Functions

func TableID

func TableID() uint

Types

type Agent

type Agent interface {
	// Add route to a router
	Add(route Route) error
	// Flush all existing routes for this router
	Flush() error
}

Agent is stateless and is responsible for creating and deleting source based routes.

Used by implementers.

type GatewayRetriever

type GatewayRetriever interface {
	// Default retrieves a default gateway
	Default(ipv6 bool) (netip.Addr, net.Interface, error)
}

GatewayRetriever is responsible for retrieving default gateway in current system

type IPGatewayRetriever

type IPGatewayRetriever struct{}

IPGatewayRetriever retrieves default gateway using ip command

func (IPGatewayRetriever) Default

func (r IPGatewayRetriever) Default(ipv6 bool) (netip.Addr, net.Interface, error)

Default retrieves a default gateway using ip route command

type PolicyAgent

type PolicyAgent interface {
	SetupRoutingRules(net.Interface, bool, bool) error
	CleanupRouting() error
	TableID() uint
}

PolicyAgent is stateless and is responsible for creating and deleting policy based routes.

Used by implementers.

type PolicyRouter

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

PolicyRouter is responsible for changing one routing agent over another.

Thread-safe.

func NewPolicyRouter

func NewPolicyRouter(noop, working PolicyAgent, enabled bool) *PolicyRouter

func (*PolicyRouter) CleanupRouting

func (p *PolicyRouter) CleanupRouting() error

func (*PolicyRouter) Disable

func (p *PolicyRouter) Disable() error

func (*PolicyRouter) Enable

func (p *PolicyRouter) Enable() error

func (*PolicyRouter) IsEnabled

func (p *PolicyRouter) IsEnabled() bool

func (*PolicyRouter) SetupRoutingRules

func (p *PolicyRouter) SetupRoutingRules(iface net.Interface, ipv6, enableLocal bool) error

func (*PolicyRouter) TableID

func (p *PolicyRouter) TableID() uint

type PolicyService

type PolicyService interface {
	SetupRoutingRules(net.Interface, bool, bool) error
	CleanupRouting() error
	// TableID of the routing table.
	TableID() uint
	// Enable sets up previously remembered rules.
	Enable() error
	// Disable remembers previously added rules before clearing them.
	Disable() error
	IsEnabled() bool
}

Service is stateful and updates system routing configuration by using the appropriate agent.

Used by callers.

type RPFilterManager

type RPFilterManager interface {
	// Set sets the RP filter value to the one which allows policy
	// based routing if necessary
	Set() error
	// Unset sets the RP filter value to the one which was set
	// before
	Unset() error
}

RPFilterManager should handle the setting and unsetting of the desired RP filter configuration value

type Route

type Route struct {
	Gateway netip.Addr
	Subnet  netip.Prefix
	Device  net.Interface
	TableID uint
}

Route defines a route to Subnet through the specified Gateway

func (*Route) IsEqual

func (r *Route) IsEqual(to Route) bool

IsEqual compares to routes for equality.

type Router

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

Router is responsible for changing one routing agent over another.

Thread-safe.

func NewRouter

func NewRouter(noop, working Agent, enabled bool) *Router

func (*Router) Add

func (r *Router) Add(route Route) error

func (*Router) Disable

func (r *Router) Disable() error

func (*Router) Enable

func (r *Router) Enable(tableID uint) error

func (*Router) Flush

func (r *Router) Flush() error

func (*Router) IsEnabled

func (r *Router) IsEnabled() bool

type Service

type Service interface {
	// Add route to a router
	Add(route Route) error
	// Flush all existing routes for this router
	Flush() error
	// Enable adds previously remembered routes.
	Enable(tableID uint) error
	// Disable remembers previously added routes before flushing them.
	Disable() error
	// IsEnabled reports route setting status
	IsEnabled() bool
}

Service is stateful and updates system routing configuration by using the appropriate agent.

Used by callers.

type SysctlRPFilterManager

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

func NewSysctlRPFilterManager

func NewSysctlRPFilterManager() *SysctlRPFilterManager

func (*SysctlRPFilterManager) Set

func (s *SysctlRPFilterManager) Set() error

func (*SysctlRPFilterManager) Unset

func (s *SysctlRPFilterManager) Unset() error

Directories

Path Synopsis
Package iprouter provides Go API for interacting with ip route.
Package iprouter provides Go API for interacting with ip route.
Package iprule provides Go API for interacting with ip rule.
Package iprule provides Go API for interacting with ip rule.
Package norouter implements noop router.
Package norouter implements noop router.
Package norule implements noop policy router.
Package norule implements noop policy router.

Jump to

Keyboard shortcuts

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