make it harder to insert invalid routes (#2371)
* make it harder to insert invalid routes Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * dont panic if node is not available for route Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> * update changelog Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com> --------- Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
c1f42cdf4b
commit
615ee5df75
4 changed files with 34 additions and 3 deletions
|
@ -13,7 +13,7 @@ import (
|
|||
type Route struct {
|
||||
gorm.Model
|
||||
|
||||
NodeID uint64
|
||||
NodeID uint64 `gorm:"not null"`
|
||||
Node *Node
|
||||
|
||||
// TODO(kradalby): change this custom type to netip.Prefix
|
||||
|
@ -79,7 +79,6 @@ func (rs Routes) Proto() []*v1.Route {
|
|||
for _, route := range rs {
|
||||
protoRoute := v1.Route{
|
||||
Id: uint64(route.ID),
|
||||
Node: route.Node.Proto(),
|
||||
Prefix: route.Prefix.String(),
|
||||
Advertised: route.Advertised,
|
||||
Enabled: route.Enabled,
|
||||
|
@ -88,6 +87,10 @@ func (rs Routes) Proto() []*v1.Route {
|
|||
UpdatedAt: timestamppb.New(route.UpdatedAt),
|
||||
}
|
||||
|
||||
if route.Node != nil {
|
||||
protoRoute.Node = route.Node.Proto()
|
||||
}
|
||||
|
||||
if route.DeletedAt.Valid {
|
||||
protoRoute.DeletedAt = timestamppb.New(route.DeletedAt.Time)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue