mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-01 20:43:43 +01:00
2475473227
All routes are now installed in a custom netbird routing table. Management and wireguard traffic is now marked with a custom fwmark. When the mark is present the traffic is routed via the main routing table, bypassing the VPN. When the mark is absent the traffic is routed via the netbird routing table, if: - there's no match in the main routing table - it would match the default route in the routing table IPv6 traffic is blocked when a default route IPv4 route is configured to avoid leakage.
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package routemanager
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
firewall "github.com/netbirdio/netbird/client/firewall/manager"
|
|
"github.com/netbirdio/netbird/client/internal/listener"
|
|
"github.com/netbirdio/netbird/iface"
|
|
"github.com/netbirdio/netbird/route"
|
|
)
|
|
|
|
// MockManager is the mock instance of a route manager
|
|
type MockManager struct {
|
|
UpdateRoutesFunc func(updateSerial uint64, newRoutes []*route.Route) error
|
|
StopFunc func()
|
|
}
|
|
|
|
func (m *MockManager) Init() error {
|
|
return nil
|
|
}
|
|
|
|
// InitialRouteRange mock implementation of InitialRouteRange from Manager interface
|
|
func (m *MockManager) InitialRouteRange() []string {
|
|
return nil
|
|
}
|
|
|
|
// UpdateRoutes mock implementation of UpdateRoutes from Manager interface
|
|
func (m *MockManager) UpdateRoutes(updateSerial uint64, newRoutes []*route.Route) error {
|
|
if m.UpdateRoutesFunc != nil {
|
|
return m.UpdateRoutesFunc(updateSerial, newRoutes)
|
|
}
|
|
return fmt.Errorf("method UpdateRoutes is not implemented")
|
|
}
|
|
|
|
// Start mock implementation of Start from Manager interface
|
|
func (m *MockManager) Start(ctx context.Context, iface *iface.WGIface) {
|
|
}
|
|
|
|
// SetRouteChangeListener mock implementation of SetRouteChangeListener from Manager interface
|
|
func (m *MockManager) SetRouteChangeListener(listener listener.NetworkChangeListener) {
|
|
|
|
}
|
|
|
|
func (m *MockManager) EnableServerRouter(firewall firewall.Manager) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
// Stop mock implementation of Stop from Manager interface
|
|
func (m *MockManager) Stop() {
|
|
if m.StopFunc != nil {
|
|
m.StopFunc()
|
|
}
|
|
}
|