diff options
| author | Alex Chan <alexc@tailscale.com> | 2025-11-25 10:22:08 +0000 |
|---|---|---|
| committer | Alex Chan <alex@alexwlchan.net> | 2025-11-25 19:05:13 +0000 |
| commit | b38dd1ae06c456fcd65e31e642990a5f1520c63b (patch) | |
| tree | edb03f31adf6f27930630d39a01208e61c4d9dfa /util/execqueue/execqueue.go | |
| parent | f4a4bab105a89da491bb9f5ae1effb9b4f44b7f2 (diff) | |
| download | tailscale-b38dd1ae06c456fcd65e31e642990a5f1520c63b.tar.xz tailscale-b38dd1ae06c456fcd65e31e642990a5f1520c63b.zip | |
ipn/ipnlocal: don't panic if there are no suitable exit nodes
In suggestExitNodeLocked, if no exit node candidates have a home DERP or
valid location info, `bestCandidates` is an empty slice. This slice is
passed to `selectNode` (`randomNode` in prod):
```go func randomNode(nodes views.Slice[tailcfg.NodeView], …) tailcfg.NodeView {
…
return nodes.At(rand.IntN(nodes.Len()))
}
```
An empty slice becomes a call to `rand.IntN(0)`, which panics.
This patch changes the behaviour, so if we've filtered out all the
candidates before calling `selectNode`, reset the list and then pick
from any of the available candidates.
This patch also updates our tests to give us more coverage of `randomNode`,
so we can spot other potential issues.
Updates #17661
Change-Id: I63eb5e4494d45a1df5b1f4b1b5c6d5576322aa72
Signed-off-by: Alex Chan <alexc@tailscale.com>
Diffstat (limited to 'util/execqueue/execqueue.go')
0 files changed, 0 insertions, 0 deletions
