tailscale/tstest
Brad Fitzpatrick f3a117e813 net/tsdial: run happy eyeballs across A and AAAA in UserDial
When tailscaled is running in userspace-networking mode behind an
exit node (e.g. as a SOCKS5 proxy), it resolves a hostname and then
dials a single resolved IP through the tunnel. If the name has both
A and AAAA, Go's net.Resolver merges them and we pick ips[0], which
on an IPv6-native host is usually AAAA. If the exit node has no IPv6
egress (or vice versa), the dial fails silently through the tunnel
and the user sees a hang.

Resolve all candidates and race connect attempts across address
families with a 300ms happy-eyeballs delay, matching Go's net.Dialer
default and the existing pattern in net/dnscache (commit ee0a03b14).
First success wins; losers are cancelled and any conns they produce
are closed. A failBoost channel wakes the launcher when a connect
fails fast (e.g. ICMP "no route" via the tunnel) so we don't sit on
the 300ms timer when the answer is already known.

userDialResolve is refactored into userDialResolveAll (returns the
full candidate list) plus a thin single-IP wrapper for callers like
UserDialPlan that don't race. UserDial's per-IP dispatch (netstack
vs peer dialer vs SystemDial vs std) is extracted to dialOneUser so
each candidate can route correctly on its own merits.

Also fix serveDial in localapi to pass the original hostname to
UserDial rather than a pre-resolved IP, so the race can fire.

This fix is single-ended: it works against any exit node, including
old ones, with no protocol changes. The trade-off versus filtering
on the exit-node side via PeerAPI DoH is that every dial through an
unreachable-family exit node costs one failed connect attempt per
cache window, rather than zero, which is acceptable given the
simplicity.

Fixes #19792
Fixes #13257

Change-Id: I9d7645d0034caf3ee22ecdd8070798353f77e94b
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2026-05-20 18:35:55 -07:00
..
archtest all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
chonktest all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
deptest all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
integration tstest/integration/testcontrol: fix serveMap read-modify-write race 2026-05-20 18:29:58 -07:00
iosdeps wgengine/netstack, net/ping: stop using pro-bing and use our net/ping instead 2026-05-04 14:05:24 -07:00
jsdeps all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
largetailnet tstest/largetailnet, tstest/integration/testcontrol: add in-process large-tailnet benchmark 2026-04-27 11:47:12 -07:00
mts all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
natlab net/tsdial: run happy eyeballs across A and AAAA in UserDial 2026-05-20 18:35:55 -07:00
nettest go.toolchain.branch: switch to Go 1.26 2026-03-04 21:57:05 -08:00
tailmac tstest/natlab/vmtest: add macOS VM snapshot caching for fast test starts 2026-04-29 08:17:13 -07:00
tkatest all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tlstest all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tools all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
typewalk all: use Go 1.26 things, run most gofix modernizers 2026-03-06 13:32:03 -08:00
allocs.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
clock_test.go cmd/vet: add subtestnames analyzer; fix all existing violations 2026-04-05 15:52:51 -07:00
clock.go tstest/clock: explain what happens if you don't set a Start time 2026-04-28 00:15:46 +02:00
kernel_linux_test.go tstest: fix kernel version parsing for Debian-style version strings 2026-04-14 07:11:44 -07:00
kernel_linux.go tstest: fix kernel version parsing for Debian-style version strings 2026-04-14 07:11:44 -07:00
kernel_other.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
log_test.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
log.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
reflect.go types/ptr: deprecate ptr.To, use Go 1.26 new 2026-03-05 20:13:18 -08:00
resource_test.go cmd/vet: add subtestnames analyzer; fix all existing violations 2026-04-05 15:52:51 -07:00
resource.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
test-wishlist.md wf: allow limited broadcast to/from permitted interfaces when using an exit node on Windows 2026-01-23 18:30:38 -06:00
tstest_test.go all: remove AUTHORS file and references to it 2026-01-23 15:49:45 -08:00
tstest.go tstest: add AssertNotParallel helper 2026-04-13 16:14:33 -07:00