Documentation ¶
Index ¶
- Constants
- Variables
- func EnableIPForwarding() error
- func GetRoutesFromTable() ([]netip.Prefix, error)
- func IsAddrRouted(addr netip.Addr, vpnRoutes []netip.Prefix) (bool, netip.Prefix)
- type ExclusionCounter
- type Nexthop
- type SysOps
- func (r *SysOps) AddVPNRoute(prefix netip.Prefix, intf *net.Interface) error
- func (r *SysOps) CleanupRouting() error
- func (r *SysOps) RemoveVPNRoute(prefix netip.Prefix, intf *net.Interface) error
- func (r *SysOps) SetupRouting(initAddresses []net.IP) (_ nbnet.AddHookFunc, _ nbnet.RemoveHookFunc, err error)
Constants ¶
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 ¶
var ErrRoutingIsSeparate = errors.New("routing is separate")
var ErrTableIDExists = errors.New("ID exists with different name")
Functions ¶
func EnableIPForwarding ¶
func EnableIPForwarding() error
func GetRoutesFromTable ¶ added in v0.28.7
Types ¶
type ExclusionCounter ¶
type ExclusionCounter = refcounter.Counter[any, Nexthop]
type SysOps ¶
type SysOps struct {
// contains filtered or unexported fields
}
func (*SysOps) AddVPNRoute ¶
func (*SysOps) CleanupRouting ¶
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 (*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.