mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-05 08:54:11 -04:00
Feature/android dns (#943)
Support DNS feature on mobile systems --------- Co-authored-by: Givi Khojanashvili <gigovich@gmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
type Manager interface {
|
||||
UpdateRoutes(updateSerial uint64, newRoutes []*route.Route) error
|
||||
SetRouteChangeListener(listener RouteListener)
|
||||
InitialRouteRange() []string
|
||||
Stop()
|
||||
}
|
||||
|
||||
@@ -51,10 +52,6 @@ func NewManager(ctx context.Context, pubKey string, wgInterface *iface.WGIface,
|
||||
if runtime.GOOS == "android" {
|
||||
cr := dm.clientRoutes(initialRoutes)
|
||||
dm.notifier.setInitialClientRoutes(cr)
|
||||
networks := readRouteNetworks(cr)
|
||||
|
||||
// make sense to call before create interface
|
||||
wgInterface.SetInitialRoutes(networks)
|
||||
}
|
||||
return dm
|
||||
}
|
||||
@@ -94,6 +91,11 @@ func (m *DefaultManager) SetRouteChangeListener(listener RouteListener) {
|
||||
m.notifier.setListener(listener)
|
||||
}
|
||||
|
||||
// InitialRouteRange return the list of initial routes. It used by mobile systems
|
||||
func (m *DefaultManager) InitialRouteRange() []string {
|
||||
return m.notifier.initialRouteRanges()
|
||||
}
|
||||
|
||||
func (m *DefaultManager) updateClientNetworks(updateSerial uint64, networks map[string][]*route.Route) {
|
||||
// removing routes that do not exist as per the update from the Management service.
|
||||
for id, client := range m.clientNetworks {
|
||||
@@ -163,11 +165,3 @@ func (m *DefaultManager) clientRoutes(initialRoutes []*route.Route) []*route.Rou
|
||||
}
|
||||
return rs
|
||||
}
|
||||
|
||||
func readRouteNetworks(cr []*route.Route) []string {
|
||||
routesNetworks := make([]string, 0)
|
||||
for _, r := range cr {
|
||||
routesNetworks = append(routesNetworks, r.Network.String())
|
||||
}
|
||||
return routesNetworks
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user