MCPcopy Index your code
hub / github.com/tailscale/tailscale / printPeerConcise

Function printPeerConcise

types/netmap/netmap.go:383–419  ·  view source on GitHub ↗

printPeerConcise appends to buf a line representing the peer p. If this function is changed to access different fields of p, keep in nodeConciseEqual in sync.

(buf *strings.Builder, p tailcfg.NodeView)

Source from the content-addressed store, hash-verified

381// If this function is changed to access different fields of p, keep
382// in nodeConciseEqual in sync.
383func printPeerConcise(buf *strings.Builder, p tailcfg.NodeView) {
384 aip := make([]string, p.AllowedIPs().Len())
385 for i, a := range p.AllowedIPs().All() {
386 s := strings.TrimSuffix(a.String(), "/32")
387 aip[i] = s
388 }
389
390 epStrs := make([]string, p.Endpoints().Len())
391 for i, ep := range p.Endpoints().All() {
392 e := ep.String()
393 // Align vertically on the ':' between IP and port
394 colon := strings.IndexByte(e, ':')
395 spaces := 0
396 for colon > 0 && len(e)+spaces-colon < 6 {
397 spaces++
398 colon--
399 }
400 epStrs[i] = fmt.Sprintf("%21v", e+strings.Repeat(" ", spaces))
401 }
402
403 derp := fmt.Sprintf("D%d", p.HomeDERP())
404
405 var discoShort string
406 if !p.DiscoKey().IsZero() {
407 discoShort = p.DiscoKey().ShortString() + " "
408 }
409
410 // Most of the time, aip is just one element, so format the
411 // table to look good in that case. This will also make multi-
412 // subnet nodes stand out visually.
413 fmt.Fprintf(buf, " %v %s%-2v %-15v : %v\n",
414 p.Key().ShortString(),
415 discoShort,
416 derp,
417 strings.Join(aip, " "),
418 strings.Join(epStrs, " "))
419}
420
421// nodeConciseEqual reports whether a and b are equal for the fields accessed by printPeerConcise.
422func nodeConciseEqual(a, b tailcfg.NodeView) bool {

Callers 2

ConciseMethod · 0.85
ConciseDiffFromMethod · 0.85

Calls 10

AllowedIPsMethod · 0.80
EndpointsMethod · 0.80
HomeDERPMethod · 0.80
DiscoKeyMethod · 0.80
LenMethod · 0.65
AllMethod · 0.65
StringMethod · 0.65
IsZeroMethod · 0.65
KeyMethod · 0.65
ShortStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…