MCPcopy
hub / github.com/tailscale/tailscale / initDisplayNames

Function initDisplayNames

control/controlclient/direct.go:1450–1466  ·  view source on GitHub ↗

initDisplayNames mutates any tailcfg.Nodes in resp to populate their display names, calling InitDisplayNames on each. The magicDNSSuffix used is based on selfNode.

(selfNode tailcfg.NodeView, resp *tailcfg.MapResponse)

Source from the content-addressed store, hash-verified

1448//
1449// The magicDNSSuffix used is based on selfNode.
1450func initDisplayNames(selfNode tailcfg.NodeView, resp *tailcfg.MapResponse) {
1451 if resp.Node == nil && len(resp.Peers) == 0 && len(resp.PeersChanged) == 0 {
1452 // Fast path for a common case (delta updates). No need to compute
1453 // magicDNSSuffix.
1454 return
1455 }
1456 magicDNSSuffix := netmap.MagicDNSSuffixOfNodeName(selfNode.Name())
1457 if resp.Node != nil {
1458 resp.Node.InitDisplayNames(magicDNSSuffix)
1459 }
1460 for _, n := range resp.Peers {
1461 n.InitDisplayNames(magicDNSSuffix)
1462 }
1463 for _, n := range resp.PeersChanged {
1464 n.InitDisplayNames(magicDNSSuffix)
1465 }
1466}
1467
1468// decode JSON decodes the res.Body into v.
1469func decode(res *http.Response, v any) error {

Callers 2

TestNetmapForResponseFunction · 0.85

Calls 3

MagicDNSSuffixOfNodeNameFunction · 0.92
InitDisplayNamesMethod · 0.80
NameMethod · 0.65

Tested by 1

TestNetmapForResponseFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…