mirror of
https://github.com/tailscale/tailscale.git
synced 2026-03-29 11:42:02 -04:00
wgengine: search randomly for unused port instead of in contiguous range (#18974)
In TestUserspaceEnginePortReconfig, when selecting a port, use a random offset rather than searching in a continguous range in case there is a range that is blocked Updates tailscale/tailscale#2855 Signed-off-by: kari-ts <kari@tailscale.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/netip"
|
||||
"os"
|
||||
"reflect"
|
||||
@@ -175,8 +176,8 @@ func TestUserspaceEnginePortReconfig(t *testing.T) {
|
||||
var ue *userspaceEngine
|
||||
ht := health.NewTracker(bus)
|
||||
reg := new(usermetric.Registry)
|
||||
for i := range 100 {
|
||||
attempt := uint16(defaultPort + i)
|
||||
for range 100 {
|
||||
attempt := uint16(defaultPort + rand.Intn(1000))
|
||||
e, err := NewFakeUserspaceEngine(t.Logf, attempt, &knobs, ht, reg, bus)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user