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 ShutdownState
- type SysOps
- func (r *SysOps) AddVPNRoute(prefix netip.Prefix, intf *net.Interface) error
- func (r *SysOps) CleanupRouting(stateManager *statemanager.Manager) error
- func (r *SysOps) RemoveVPNRoute(prefix netip.Prefix, intf *net.Interface) error
- func (r *SysOps) SetupRouting(initAddresses []net.IP, stateManager *statemanager.Manager) (_ 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[netip.Prefix, struct{}, Nexthop]
type ShutdownState ¶ added in v0.30.3
type ShutdownState ExclusionCounter
func (*ShutdownState) Cleanup ¶ added in v0.30.3
func (s *ShutdownState) Cleanup() error
func (*ShutdownState) MarshalJSON ¶ added in v0.32.0
func (s *ShutdownState) MarshalJSON() ([]byte, error)
func (*ShutdownState) Name ¶ added in v0.30.3
func (s *ShutdownState) Name() string
func (*ShutdownState) UnmarshalJSON ¶ added in v0.32.0
func (s *ShutdownState) UnmarshalJSON(data []byte) error
type SysOps ¶
type SysOps struct {
// contains filtered or unexported fields
}
func (*SysOps) AddVPNRoute ¶
func (*SysOps) CleanupRouting ¶
func (r *SysOps) CleanupRouting(stateManager *statemanager.Manager) 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 (*SysOps) SetupRouting ¶
func (r *SysOps) SetupRouting(initAddresses []net.IP, stateManager *statemanager.Manager) (_ 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.