mirror of
https://github.com/juanfont/headscale.git
synced 2025-10-28 10:51:44 +01:00
dont panic if node is not available for route
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
27bb1201f4
commit
e10dfe08b9
@ -251,10 +251,15 @@ func routesToPtables(routes []*v1.Route) pterm.TableData {
|
|||||||
isPrimaryStr = strconv.FormatBool(route.GetIsPrimary())
|
isPrimaryStr = strconv.FormatBool(route.GetIsPrimary())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nodeName string
|
||||||
|
if route.GetNode() != nil {
|
||||||
|
nodeName = route.GetNode().GetGivenName()
|
||||||
|
}
|
||||||
|
|
||||||
tableData = append(tableData,
|
tableData = append(tableData,
|
||||||
[]string{
|
[]string{
|
||||||
strconv.FormatUint(route.GetId(), Base10),
|
strconv.FormatUint(route.GetId(), Base10),
|
||||||
route.GetNode().GetGivenName(),
|
nodeName,
|
||||||
route.GetPrefix(),
|
route.GetPrefix(),
|
||||||
strconv.FormatBool(route.GetAdvertised()),
|
strconv.FormatBool(route.GetAdvertised()),
|
||||||
strconv.FormatBool(route.GetEnabled()),
|
strconv.FormatBool(route.GetEnabled()),
|
||||||
|
|||||||
@ -79,7 +79,6 @@ func (rs Routes) Proto() []*v1.Route {
|
|||||||
for _, route := range rs {
|
for _, route := range rs {
|
||||||
protoRoute := v1.Route{
|
protoRoute := v1.Route{
|
||||||
Id: uint64(route.ID),
|
Id: uint64(route.ID),
|
||||||
Node: route.Node.Proto(),
|
|
||||||
Prefix: route.Prefix.String(),
|
Prefix: route.Prefix.String(),
|
||||||
Advertised: route.Advertised,
|
Advertised: route.Advertised,
|
||||||
Enabled: route.Enabled,
|
Enabled: route.Enabled,
|
||||||
@ -88,6 +87,10 @@ func (rs Routes) Proto() []*v1.Route {
|
|||||||
UpdatedAt: timestamppb.New(route.UpdatedAt),
|
UpdatedAt: timestamppb.New(route.UpdatedAt),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if route.Node != nil {
|
||||||
|
protoRoute.Node = route.Node.Proto()
|
||||||
|
}
|
||||||
|
|
||||||
if route.DeletedAt.Valid {
|
if route.DeletedAt.Valid {
|
||||||
protoRoute.DeletedAt = timestamppb.New(route.DeletedAt.Time)
|
protoRoute.DeletedAt = timestamppb.New(route.DeletedAt.Time)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user