route

package
v0.0.0-...-2a5a317 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package route contains the OS specific route manipulation implementation.

Index

Constants

View Source
const (
	// MetadataRouteDestination is the destination of the route to the metadata
	// server.
	MetadataRouteDestination = "169.254.169.254"
	// MetadataRouteGateway is the gateway of the route to the metadata server.
	MetadataRouteGateway = "0.0.0.0"
)

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, route Handle) error

Add adds a route to the system.

func Delete

func Delete(ctx context.Context, route Handle) error

Delete deletes a route from the system.

func RemoveRoutes

func RemoveRoutes(ctx context.Context, iface string) error

RemoveRoutes removes all the routes managed/installed by us for the given interface.

Types

type Handle

type Handle struct {
	// Destination is the destination of the route.
	Destination *address.IPAddr
	// Gateway is the gateway of the route.
	Gateway *address.IPAddr
	// InterfaceIndex is the interface index of the route.
	InterfaceIndex uint32
	// InterfaceName is the name of the interface the route should be added to.
	// It's only relevant for linux backend implementation.
	InterfaceName string
	// Metric is the metric of the route.
	Metric uint32
	// Type is the type of the route. On linux systems it's the type of the route
	// (e.g. local, remote, etc). It's only relevant for linux backend
	// implementation.
	Type string
	// Table is the table of the route. It's only relevant for linux backend
	// implementation.
	Table string
	// Persistent indicates whether the route is persistent. It's mostly relevant
	// for windows backend implementation.
	Persistent bool
	// Proto is the proto of the route. It's only relevant for linux backend
	// implementation.
	Proto string
	// Source is the source of the route. It's only relevant for linux backend
	// implementation.
	Source *address.IPAddr
	// Scope is the scope of the route. It's only relevant for linux backend
	// implementation.
	Scope string
}

Handle represents a network route.

func Find

func Find(ctx context.Context, opts Options) ([]Handle, error)

Find finds routes based on the provided options.

func MissingRoutes

func MissingRoutes(ctx context.Context, iface string, wantedRoutes address.IPAddressMap) ([]Handle, error)

MissingRoutes given a map of wanted routes addresses returns the routes that are missing from the system.

func Table

func Table() ([]Handle, error)

Table returns the route table.

type Options

type Options struct {
	// Type is the type of the route.
	Type string
	// Table is the table of the route.
	Table string
	// Scope is the scope of the route.
	Scope string
	// Proto is the proto of the route.
	Proto string
	// Device is the device of the route.
	Device string
}

Options wraps route operations options.

Jump to

Keyboard shortcuts

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