mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-09 23:27:58 +02:00
Refactor Route IDs (#1891)
This commit is contained in:
@ -36,6 +36,12 @@ const (
|
||||
IPv6Network
|
||||
)
|
||||
|
||||
type ID string
|
||||
|
||||
type NetID string
|
||||
|
||||
type HAMap map[HAUniqueID][]*Route
|
||||
|
||||
// NetworkType route network type
|
||||
type NetworkType int
|
||||
|
||||
@ -65,11 +71,11 @@ func ToPrefixType(prefix string) NetworkType {
|
||||
|
||||
// Route represents a route
|
||||
type Route struct {
|
||||
ID string `gorm:"primaryKey"`
|
||||
ID ID `gorm:"primaryKey"`
|
||||
// AccountID is a reference to Account that this object belongs
|
||||
AccountID string `gorm:"index"`
|
||||
Network netip.Prefix `gorm:"serializer:json"`
|
||||
NetID string
|
||||
NetID NetID
|
||||
Description string
|
||||
Peer string
|
||||
PeerGroups []string `gorm:"serializer:json"`
|
||||
@ -165,8 +171,3 @@ func compareList(list, other []string) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// GetHAUniqueID returns a highly available route ID by combining Network ID and Network range address
|
||||
func GetHAUniqueID(input *Route) string {
|
||||
return input.NetID + "-" + input.Network.String()
|
||||
}
|
||||
|
Reference in New Issue
Block a user