router

package
v0.6.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: 2 Imported by: 1 module, 8 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

Overview

Package router defines the Router interface for OS-level route table queries used in TUN (virtual network device) mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(opts *Options)

Option is a functional option for configuring Options.

func IDOption added in v0.3.2

func IDOption(id string) Option

IDOption sets the routing table ID.

type Options

type Options struct {
	// ID is a unique identifier for the routing table.
	ID string
}

Options holds the runtime parameters for a route query.

type Route

type Route struct {
	// Net is the destination network, e.g. "192.168.0.0/16", "172.10.10.0/24".
	// Deprecated: use Dst instead.
	Net *net.IPNet
	// Dst is the destination address or network.
	Dst string
	// Gateway is the gateway address for the destination network.
	Gateway string
}

Route represents an entry in the system routing table.

type Router

type Router interface {
	// GetRoute returns the route for the given destination, or nil if no
	// matching route is found.
	GetRoute(ctx context.Context, dst string, opts ...Option) *Route
}

Router queries the OS-level route table. This is used in TUN mode where TNET acts as a virtual network device and needs to determine how to route packets based on the system's routing table.

Jump to

Keyboard shortcuts

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