Start sets up all the handlers so netstack can start working. Implements wgengine.FakeImpl. The provided LocalBackend interface can be either nil, for special case users of netstack that don't have a LocalBackend, or a non-nil *ipnlocal.LocalBackend. Any other type will cause Start to panic. Start
(b LocalBackend)
| 631 | // Start currently (2026-03-11) never returns a non-nil error, but maybe it did |
| 632 | // in the past and maybe it will in the future. |
| 633 | func (ns *Impl) Start(b LocalBackend) error { |
| 634 | switch b := b.(type) { |
| 635 | case nil: |
| 636 | // No backend, so just continue with ns.lb unset. |
| 637 | case *ipnlocal.LocalBackend: |
| 638 | if b == nil { |
| 639 | panic("nil LocalBackend") |
| 640 | } |
| 641 | ns.lb = b |
| 642 | default: |
| 643 | panic(fmt.Sprintf("unexpected type for LocalBackend: %T", b)) |
| 644 | } |
| 645 | tcpFwd := tcp.NewForwarder(ns.ipstack, tcpRXBufDefSize, maxInFlightConnectionAttempts(), ns.acceptTCP) |
| 646 | udpFwd := udp.NewForwarder(ns.ipstack, ns.acceptUDPNoICMP) |
| 647 | ns.ipstack.SetTransportProtocolHandler(tcp.ProtocolNumber, ns.wrapTCPProtocolHandler(tcpFwd.HandlePacket)) |
| 648 | ns.ipstack.SetTransportProtocolHandler(udp.ProtocolNumber, ns.wrapUDPProtocolHandler(udpFwd.HandlePacket)) |
| 649 | ns.injectWG.Go(func() { |
| 650 | ns.inject() |
| 651 | }) |
| 652 | if ns.ready.Swap(true) { |
| 653 | panic("already started") |
| 654 | } |
| 655 | return nil |
| 656 | } |
| 657 | |
| 658 | func (ns *Impl) addSubnetAddress(ip netip.Addr) { |
| 659 | ns.mu.Lock() |
nothing calls this directly
no test coverage detected