diff options
| author | kari-ts <kari@tailscale.com> | 2025-06-16 11:16:31 -0700 |
|---|---|---|
| committer | kari-ts <kari@tailscale.com> | 2025-06-16 11:18:17 -0700 |
| commit | a45bc8aa5a752c266b9e15d2605680f888ede054 (patch) | |
| tree | 7098447e7f05cf5bf51651a2310e71cba95d49a9 | |
| parent | 866614202c96fa1e5116116acf50834ee787ed6c (diff) | |
| download | tailscale-kari/nilbus.tar.xz tailscale-kari/nilbus.zip | |
ipn/ipnlocal: fix nil bus panickari/nilbus
Android was hitting a panic due to the event bus not being set when creating a new local backend. This adds a nil check and fallback if the eventbus has not been initiated.
Updates #cleanup
Signed-off-by: kari-ts <kari@tailscale.com>
| -rw-r--r-- | ipn/ipnlocal/local.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index cd30e92bb..1f73c5d31 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -515,7 +515,16 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo captiveCancel: nil, // so that we start checkCaptivePortalLoop when Running needsCaptiveDetection: make(chan bool), } - nb := newNodeBackend(ctx, b.sys.Bus.Get()) + var bus *eventbus.Bus + if b.sys != nil { + bus = b.sys.Bus.Get() + } + if bus == nil { + log.Printf("WARNING: sys.Bus is not set; using fallback bus.") + bus = eventbus.New() + } + nb := newNodeBackend(ctx, bus) + b.currentNodeAtomic.Store(nb) nb.ready() |
