Documentation ¶
Index ¶
- Constants
- Variables
- func GetNextHop(ip netip.Addr) (netip.Addr, *net.Interface, error)
- type AddRouteFunc
- type DefaultManager
- func (m *DefaultManager) EnableServerRouter(firewall firewall.Manager) error
- func (m *DefaultManager) GetClientRoutes() map[route.HAUniqueID]*clientNetwork
- func (m *DefaultManager) GetRouteSelector() *routeselector.RouteSelector
- func (m *DefaultManager) Init() (peer.BeforeAddPeerHookFunc, peer.AfterRemovePeerHookFunc, error)
- func (m *DefaultManager) InitialRouteRange() []string
- func (m *DefaultManager) SetRouteChangeListener(listener listener.NetworkChangeListener)
- func (m *DefaultManager) Stop()
- func (m *DefaultManager) TriggerSelection(networks route.HAMap)
- func (m *DefaultManager) UpdateRoutes(updateSerial uint64, newRoutes []*route.Route) (map[route.ID]*route.Route, route.HAMap, error)
- type Manager
- type MockManager
- func (m *MockManager) EnableServerRouter(firewall firewall.Manager) error
- func (m *MockManager) GetRouteSelector() *routeselector.RouteSelector
- func (m *MockManager) Init() (peer.BeforeAddPeerHookFunc, peer.AfterRemovePeerHookFunc, error)
- func (m *MockManager) InitialRouteRange() []string
- func (m *MockManager) SetRouteChangeListener(listener listener.NetworkChangeListener)
- func (m *MockManager) Start(ctx context.Context, iface *iface.WGIface)
- func (m *MockManager) Stop()
- func (m *MockManager) TriggerSelection(networks route.HAMap)
- func (m *MockManager) UpdateRoutes(updateSerial uint64, newRoutes []*route.Route) (map[route.ID]*route.Route, route.HAMap, error)
- type RemoveRouteFunc
- type RouteManager
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 ErrRouteNotAllowed = errors.New("route not allowed")
var ErrRouteNotFound = errors.New("route not found")
var ErrTableIDExists = errors.New("ID exists with different name")
Functions ¶
Types ¶
type AddRouteFunc ¶
type DefaultManager ¶
type DefaultManager struct {
// contains filtered or unexported fields
}
DefaultManager is the default instance of a route manager
func NewManager ¶
func (*DefaultManager) EnableServerRouter ¶
func (m *DefaultManager) EnableServerRouter(firewall firewall.Manager) error
func (*DefaultManager) GetClientRoutes ¶
func (m *DefaultManager) GetClientRoutes() map[route.HAUniqueID]*clientNetwork
GetClientRoutes returns the client routes
func (*DefaultManager) GetRouteSelector ¶
func (m *DefaultManager) GetRouteSelector() *routeselector.RouteSelector
GetRouteSelector returns the route selector
func (*DefaultManager) Init ¶
func (m *DefaultManager) Init() (peer.BeforeAddPeerHookFunc, peer.AfterRemovePeerHookFunc, error)
Init sets up the routing
func (*DefaultManager) InitialRouteRange ¶
func (m *DefaultManager) InitialRouteRange() []string
InitialRouteRange return the list of initial routes. It used by mobile systems
func (*DefaultManager) SetRouteChangeListener ¶
func (m *DefaultManager) SetRouteChangeListener(listener listener.NetworkChangeListener)
SetRouteChangeListener set RouteListener for route change notifier
func (*DefaultManager) Stop ¶
func (m *DefaultManager) Stop()
Stop stops the manager watchers and clean firewall rules
func (*DefaultManager) TriggerSelection ¶
func (m *DefaultManager) TriggerSelection(networks route.HAMap)
TriggerSelection triggers the selection of routes, stopping deselected watchers and starting newly selected ones
type Manager ¶
type Manager interface { Init() (peer.BeforeAddPeerHookFunc, peer.AfterRemovePeerHookFunc, error) UpdateRoutes(updateSerial uint64, newRoutes []*route.Route) (map[route.ID]*route.Route, route.HAMap, error) TriggerSelection(route.HAMap) GetRouteSelector() *routeselector.RouteSelector SetRouteChangeListener(listener listener.NetworkChangeListener) InitialRouteRange() []string EnableServerRouter(firewall firewall.Manager) error Stop() }
Manager is a route manager interface
type MockManager ¶
type MockManager struct { UpdateRoutesFunc func(updateSerial uint64, newRoutes []*route.Route) (map[route.ID]*route.Route, route.HAMap, error) TriggerSelectionFunc func(haMap route.HAMap) GetRouteSelectorFunc func() *routeselector.RouteSelector StopFunc func() }
MockManager is the mock instance of a route manager
func (*MockManager) EnableServerRouter ¶
func (m *MockManager) EnableServerRouter(firewall firewall.Manager) error
func (*MockManager) GetRouteSelector ¶
func (m *MockManager) GetRouteSelector() *routeselector.RouteSelector
GetRouteSelector mock implementation of GetRouteSelector from Manager interface
func (*MockManager) Init ¶
func (m *MockManager) Init() (peer.BeforeAddPeerHookFunc, peer.AfterRemovePeerHookFunc, error)
func (*MockManager) InitialRouteRange ¶
func (m *MockManager) InitialRouteRange() []string
InitialRouteRange mock implementation of InitialRouteRange from Manager interface
func (*MockManager) SetRouteChangeListener ¶
func (m *MockManager) SetRouteChangeListener(listener listener.NetworkChangeListener)
SetRouteChangeListener mock implementation of SetRouteChangeListener from Manager interface
func (*MockManager) Start ¶
func (m *MockManager) Start(ctx context.Context, iface *iface.WGIface)
Start mock implementation of Start from Manager interface
func (*MockManager) Stop ¶
func (m *MockManager) Stop()
Stop mock implementation of Stop from Manager interface
func (*MockManager) TriggerSelection ¶
func (m *MockManager) TriggerSelection(networks route.HAMap)
type RemoveRouteFunc ¶
type RouteManager ¶
type RouteManager struct {
// contains filtered or unexported fields
}
func NewRouteManager ¶
func NewRouteManager(addRoute AddRouteFunc, removeRoute RemoveRouteFunc) *RouteManager
func (*RouteManager) AddRouteRef ¶
func (rm *RouteManager) AddRouteRef(connID nbnet.ConnectionID, prefix netip.Prefix) error
func (*RouteManager) Flush ¶
func (rm *RouteManager) Flush() error
Flush removes all references and routes from the system
func (*RouteManager) RemoveRouteRef ¶
func (rm *RouteManager) RemoveRouteRef(connID nbnet.ConnectionID) error