mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
randomServers drew indices with rand.Intn into a dedup map, bounded by len(serverList)*2 iterations. When n approaches the number of configured servers, repeated random collisions can exhaust the iteration budget before n unique servers are collected, so the function sometimes returns fewer servers than requested even though enough exist. For example, with 2 configured servers and requestLimit==3 (capped to 2), the four allowed draws can collide and yield only a single server. If that server is down, ExternalIP fails without ever trying the other. Replace the sampling loop with rand.Perm, which produces a uniform permutation of all indices in one pass. Slicing the first n entries always yields exactly min(n, len(serverList)) distinct servers, with no probabilistic shortfall. |
||
|---|---|---|
| .. | ||
| nat.go | ||
| nat_test.go | ||
| natpmp.go | ||
| natupnp.go | ||
| natupnp_test.go | ||
| stun-list-update.sh | ||
| stun-list.txt | ||
| stun.go | ||
| stun_test.go | ||