locoBackend is like tailscaled's LocalBackend, but crazier. It serves a similar purpose (to be the hub of the world) but there's no controlclient involved, because there's no control plane.
| 207 | // but there's no controlclient involved, because there's |
| 208 | // no control plane. |
| 209 | type locoBackend struct { |
| 210 | sys tsd.System |
| 211 | priv key.NodePrivate |
| 212 | pub key.NodePublic |
| 213 | addr netip.Addr |
| 214 | addrPrefix netip.Prefix |
| 215 | ns *netstack.Impl |
| 216 | dm *tailcfg.DERPMap |
| 217 | logf logger.Logf |
| 218 | serverPub key.NodePublic // non-zero if we're a client (server's public key) |
| 219 | isServer bool |
| 220 | |
| 221 | // discoPublic returns the node's disco public key, memoized to |
| 222 | // avoid redoing the curve25519 derivation for every client that |
| 223 | // joins. |
| 224 | discoPublic func() key.DiscoPublic |
| 225 | |
| 226 | // onDERPRecv is called for non-disco DERP packets before the |
| 227 | // peer map lookup. Set before createEngine. |
| 228 | onDERPRecv func(regionID int, src key.NodePublic, pkt []byte) bool |
| 229 | |
| 230 | mu sync.Mutex |
| 231 | clients map[key.NodePublic]*tailcfg.Node // for the server |
| 232 | nm *netmap.NetworkMap |
| 233 | allowedClients map[key.NodePublic]bool // or nil map for all |
| 234 | eps []netip.AddrPort // our current local UDP endpoints, sorted |
| 235 | closeOnce sync.Once |
| 236 | } |
| 237 | |
| 238 | func (b *locoBackend) derpRegionID() int { |
| 239 | if b.dm == nil { |
nothing calls this directly
no outgoing calls
no test coverage detected