Use new machine types
This commit is contained in:
parent
8a95fe517a
commit
6477e6a583
4 changed files with 10 additions and 92 deletions
39
routes.go
39
routes.go
|
@ -1,9 +1,6 @@
|
|||
package headscale
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
"inet.af/netaddr"
|
||||
)
|
||||
|
||||
|
@ -23,12 +20,7 @@ func (h *Headscale) GetAdvertisedNodeRoutes(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
hostInfo, err := machine.GetHostInfo()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &hostInfo.RoutableIPs, nil
|
||||
return &machine.HostInfo.RoutableIPs, nil
|
||||
}
|
||||
|
||||
// Deprecated: use machine function instead
|
||||
|
@ -43,27 +35,7 @@ func (h *Headscale) GetEnabledNodeRoutes(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
data, err := machine.EnabledRoutes.MarshalJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
routesStr := []string{}
|
||||
err = json.Unmarshal(data, &routesStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
routes := make([]netaddr.IPPrefix, len(routesStr))
|
||||
for index, routeStr := range routesStr {
|
||||
route, err := netaddr.ParseIPPrefix(routeStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
routes[index] = route
|
||||
}
|
||||
|
||||
return routes, nil
|
||||
return machine.EnabledRoutes, nil
|
||||
}
|
||||
|
||||
// Deprecated: use machine function instead
|
||||
|
@ -135,12 +107,7 @@ func (h *Headscale) EnableNodeRoute(
|
|||
return errRouteIsNotAvailable
|
||||
}
|
||||
|
||||
routes, err := json.Marshal(enabledRoutes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
machine.EnabledRoutes = datatypes.JSON(routes)
|
||||
machine.EnabledRoutes = enabledRoutes
|
||||
h.db.Save(&machine)
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue