onEngineStatus is the wgengine status callback. It watches for changes to our magicsock UDP endpoints (learned via STUN and from local interfaces) and advertises them to all current peers. Tailcat has no control plane distributing endpoints, and magicsock never attempts a direct path to a peer with
(st *wgengine.Status, err error)
| 1081 | // attempts a direct path to a peer with no known endpoints, so these |
| 1082 | // advertisements are what make direct connections possible at all. |
| 1083 | func (b *locoBackend) onEngineStatus(st *wgengine.Status, err error) { |
| 1084 | if err != nil || st == nil { |
| 1085 | return |
| 1086 | } |
| 1087 | var eps []netip.AddrPort |
| 1088 | for _, ep := range st.LocalAddrs { |
| 1089 | eps = append(eps, ep.Addr) |
| 1090 | } |
| 1091 | slices.SortFunc(eps, func(a, b netip.AddrPort) int { return a.Compare(b) }) |
| 1092 | eps = slices.Compact(eps) |
| 1093 | b.mu.Lock() |
| 1094 | changed := !slices.Equal(eps, b.eps) |
| 1095 | if changed { |
| 1096 | b.eps = eps |
| 1097 | } |
| 1098 | b.mu.Unlock() |
| 1099 | if changed && len(eps) > 0 { |
| 1100 | go b.advertiseEndpoints() |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | // advertiseEndpoints sends our current UDP endpoints to every known |
| 1105 | // peer in a disco CallMeMaybe message over DERP, the same message the |
nothing calls this directly
no test coverage detected