systemops

package
v0.28.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NetbirdVPNTableID is the ID of the custom routing table used by Netbird.
	NetbirdVPNTableID = 0x1BD0
	// NetbirdVPNTableName is the name of the custom routing table used by Netbird.
	NetbirdVPNTableName = "netbird"
)

Variables

View Source
var ErrRoutingIsSeparate = errors.New("routing is separate")
View Source
var ErrTableIDExists = errors.New("ID exists with different name")

Functions

func EnableIPForwarding

func EnableIPForwarding() error

func GetRoutesFromTable added in v0.28.7

func GetRoutesFromTable() ([]netip.Prefix, error)

func IsAddrRouted

func IsAddrRouted(addr netip.Addr, vpnRoutes []netip.Prefix) (bool, netip.Prefix)

IsAddrRouted checks if the candidate address would route to the vpn, in which case it returns true and the matched prefix.

Types

type ExclusionCounter

type ExclusionCounter = refcounter.Counter[any, Nexthop]

type Nexthop

type Nexthop struct {
	IP   netip.Addr
	Intf *net.Interface
}

func GetNextHop

func GetNextHop(ip netip.Addr) (Nexthop, error)

type SysOps

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

func NewSysOps

func NewSysOps(wgInterface *iface.WGIface, notifier *notifier.Notifier) *SysOps

func (*SysOps) AddVPNRoute

func (r *SysOps) AddVPNRoute(prefix netip.Prefix, intf *net.Interface) error

func (*SysOps) CleanupRouting

func (r *SysOps) CleanupRouting() error

CleanupRouting performs a thorough cleanup of the routing configuration established by 'setupRouting'. It systematically removes the three rules and any associated routing table entries to ensure a clean state. The function uses error aggregation to report any errors encountered during the cleanup process.

func (*SysOps) RemoveVPNRoute

func (r *SysOps) RemoveVPNRoute(prefix netip.Prefix, intf *net.Interface) error

func (*SysOps) SetupRouting

func (r *SysOps) SetupRouting(initAddresses []net.IP) (_ nbnet.AddHookFunc, _ nbnet.RemoveHookFunc, err error)

SetupRouting establishes the routing configuration for the VPN, including essential rules to ensure proper traffic flow for management, locally configured routes, and VPN traffic.

Rule 1 (Main Route Precedence): Safeguards locally installed routes by giving them precedence over potential routes received and configured for the VPN. This rule is skipped for the default route and routes that are not in the main table.

Rule 2 (VPN Traffic Routing): Directs all remaining traffic to the 'NetbirdVPNTableID' custom routing table. This table is where a default route or other specific routes received from the management server are configured, enabling VPN connectivity.

Jump to

Keyboard shortcuts

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