router

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(opts ...Option) router.Router

NewRouter creates and initializes a new Router.

func ParseRoute

func ParseRoute(dst string, gateway string) *router.Route

ParseRoute parses a destination/gateway pair into a Route. The destination may be a CIDR notation network (e.g. "10.0.0.0/8") or a plain address. If dst is empty, nil is returned.

Types

type Option

type Option func(opts *options)

Option is a functional option for configuring a Router.

func FileLoaderOption

func FileLoaderOption(fileLoader loader.Loader) Option

FileLoaderOption sets the file-based loader for route data.

func HTTPLoaderOption

func HTTPLoaderOption(httpLoader loader.Loader) Option

HTTPLoaderOption sets the HTTP-based loader for route data.

func LoggerOption

func LoggerOption(logger logger.Logger) Option

LoggerOption sets the logger for the router.

func NoSysRouteOption added in v0.28.1

func NoSysRouteOption() Option

NoSysRouteOption disables automatic system route management via netlink. When set, the router only maintains in-memory routes for GetRoute lookups and does not attempt to add or replace routes in the OS routing table. This is useful when another component (e.g. a TUN listener) manages system routes independently.

func RedisLoaderOption

func RedisLoaderOption(redisLoader loader.Loader) Option

RedisLoaderOption sets the Redis-based loader for route data.

func ReloadPeriodOption

func ReloadPeriodOption(period time.Duration) Option

ReloadPeriodOption sets the interval for periodic route reloading.

func RoutesOption

func RoutesOption(routes []*router.Route) Option

RoutesOption sets the static routes for the router.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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