From f1f8215cda16bbb6763c7b22f60d92201fbb4c01 Mon Sep 17 00:00:00 2001 From: Adriano Sela Aviles Date: Sun, 15 Mar 2026 10:06:40 -0700 Subject: [PATCH] types/netmap: extract service details from node cap map --- types/netmap/netmap.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/types/netmap/netmap.go b/types/netmap/netmap.go index ac95254da..db8008944 100644 --- a/types/netmap/netmap.go +++ b/types/netmap/netmap.go @@ -120,6 +120,26 @@ func (nm *NetworkMap) GetVIPServiceIPMap() tailcfg.ServiceIPMappings { return ipMaps[0] } +// GetVIPServiceDetails returns the list of VIP services that the control plane +// has approved this node to serve, including their names, assigned IP +// addresses, port requirements, and application-specific annotations. Returns +// nil if no service details are present. +func (nm *NetworkMap) GetVIPServiceDetails() []*tailcfg.ServiceDetail { + if nm == nil { + return nil + } + if !nm.SelfNode.Valid() { + return nil + } + + details, err := tailcfg.UnmarshalNodeCapViewJSON[[]*tailcfg.ServiceDetail](nm.SelfNode.CapMap(), tailcfg.NodeAttrServiceDetails) + if len(details) != 1 || err != nil { + return nil + } + + return details[0] +} + // GetIPVIPServiceMap returns a map of VIP addresses to the service // names that has the VIP address. The service names are with the // prefix "svc:".