mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:34:14 -04:00
[management] add nil handling for route domains (#4366)
This commit is contained in:
@@ -290,6 +290,9 @@ func (am *DefaultAccountManager) DeleteRoute(ctx context.Context, accountID stri
|
||||
|
||||
return transaction.DeleteRoute(ctx, accountID, string(routeID))
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete route %s: %w", routeID, err)
|
||||
}
|
||||
|
||||
am.StoreEvent(ctx, userID, string(route.ID), accountID, activity.RouteRemoved, route.EventMeta())
|
||||
|
||||
|
||||
@@ -111,7 +111,11 @@ type Route struct {
|
||||
|
||||
// EventMeta returns activity event meta related to the route
|
||||
func (r *Route) EventMeta() map[string]any {
|
||||
return map[string]any{"name": r.NetID, "network_range": r.Network.String(), "domains": r.Domains.SafeString(), "peer_id": r.Peer, "peer_groups": r.PeerGroups}
|
||||
domains := ""
|
||||
if r.Domains != nil {
|
||||
domains = r.Domains.SafeString()
|
||||
}
|
||||
return map[string]any{"name": r.NetID, "network_range": r.Network.String(), "domains": domains, "peer_id": r.Peer, "peer_groups": r.PeerGroups}
|
||||
}
|
||||
|
||||
// Copy copies a route object
|
||||
@@ -181,7 +185,7 @@ func (r *Route) GetResourceID() ResID {
|
||||
// If the route is dynamic, it returns the domains as comma-separated punycode-encoded string.
|
||||
// If the route is not dynamic, it returns the network (prefix) string.
|
||||
func (r *Route) NetString() string {
|
||||
if r.IsDynamic() {
|
||||
if r.IsDynamic() && r.Domains != nil {
|
||||
return r.Domains.SafeString()
|
||||
}
|
||||
return r.Network.String()
|
||||
|
||||
Reference in New Issue
Block a user