| 246 | } |
| 247 | |
| 248 | func (b *locoBackend) Close() error { |
| 249 | b.closeOnce.Do(func() { |
| 250 | if b.ns != nil { |
| 251 | b.ns.Close() |
| 252 | } |
| 253 | if e, ok := b.sys.Engine.GetOK(); ok { |
| 254 | e.Close() |
| 255 | } |
| 256 | if m, ok := b.sys.NetMon.GetOK(); ok { |
| 257 | m.Close() |
| 258 | } |
| 259 | if d, ok := b.sys.Dialer.GetOK(); ok { |
| 260 | d.Close() |
| 261 | } |
| 262 | if bus, ok := b.sys.Bus.GetOK(); ok { |
| 263 | bus.Close() |
| 264 | } |
| 265 | }) |
| 266 | return nil |
| 267 | } |
| 268 | |
| 269 | // Server listens for clients over a WireGuard tunnel relayed through DERP. |
| 270 | // Incoming TCP connections are dispatched via [Server.OnTCP] (for connections |