GetVIPServiceIPMap returns a map of service names to the slice of VIP addresses that correspond to the service. The service names are with the prefix "svc:". TODO(tailscale/corp##25997): cache the result of decoding the capmap so that we don't have to decode it multiple times after each netmap upda
()
| 105 | // TODO(tailscale/corp##25997): cache the result of decoding the capmap so that |
| 106 | // we don't have to decode it multiple times after each netmap update. |
| 107 | func (nm *NetworkMap) GetVIPServiceIPMap() tailcfg.ServiceIPMappings { |
| 108 | if nm == nil { |
| 109 | return nil |
| 110 | } |
| 111 | if !nm.SelfNode.Valid() { |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | ipMaps, err := tailcfg.UnmarshalNodeCapViewJSON[tailcfg.ServiceIPMappings](nm.SelfNode.CapMap(), tailcfg.NodeAttrServiceHost) |
| 116 | if len(ipMaps) != 1 || err != nil { |
| 117 | return nil |
| 118 | } |
| 119 | |
| 120 | return ipMaps[0] |
| 121 | } |
| 122 | |
| 123 | // GetIPVIPServiceMap returns a map of VIP addresses to the service |
| 124 | // names that has the VIP address. The service names are with the |
no test coverage detected