mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-29 19:43:57 +01:00
4616bc5258
Support client route management feature on Android
30 lines
726 B
Go
30 lines
726 B
Go
package internal
|
|
|
|
import (
|
|
"github.com/netbirdio/netbird/client/internal/stdnet"
|
|
"github.com/netbirdio/netbird/iface"
|
|
mgm "github.com/netbirdio/netbird/management/client"
|
|
)
|
|
|
|
func newMobileDependency(tunAdapter iface.TunAdapter, ifaceDiscover stdnet.ExternalIFaceDiscover, mgmClient *mgm.GrpcClient) (MobileDependency, error) {
|
|
md := MobileDependency{
|
|
TunAdapter: tunAdapter,
|
|
IFaceDiscover: ifaceDiscover,
|
|
}
|
|
err := md.readMap(mgmClient)
|
|
return md, err
|
|
}
|
|
|
|
func (d *MobileDependency) readMap(mgmClient *mgm.GrpcClient) error {
|
|
routes, err := mgmClient.GetRoutes()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
d.Routes = make([]string, len(routes))
|
|
for i, r := range routes {
|
|
d.Routes[i] = r.GetNetwork()
|
|
}
|
|
return nil
|
|
}
|