tailscale/cmd/tailscaled
Josh Bleecher Snyder 3c543c103a wgengine/magicsock: unify initial bind and rebind
We had two separate code paths for the initial UDP listener bind
and any subsequent rebinds.

IPv6 got left out of the rebind code.
Rather than duplicate it there, unify the two code paths.
Then improve the resulting code:

* Rebind had nested listen attempts to try the user-specified port first,
  and then fall back to :0 if that failed. Convert that into a loop.
* Initial bind tried only the user-specified port.
  Rebind tried the user-specified port and 0.
  But there are actually three ports of interest:
  The one the user specified, the most recent port in use, and 0.
  We now try all three in order, as appropriate.
* In the extremely rare case in which binding to port 0 fails,
  use a dummy net.PacketConn whose reads block until close.
  This will keep the wireguard-go receive func goroutine alive.

As a pleasant side-effect of this, if we decide that
we need to resuscitate #1796, it will now be much easier.

Fixes #1799

Co-authored-by: David Anderson <danderson@tailscale.com>
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-28 10:39:28 -07:00
..
debug.go Revert "cmd/tailscaled: split package main into main shim + package" 2021-03-25 09:06:00 -07:00
depaware.txt wgengine/magicsock: unify initial bind and rebind 2021-04-28 10:39:28 -07:00
install_darwin.go cmd/tailscaled: remove tailscaled binary on uninstall-system-daemon 2021-03-31 15:44:04 -07:00
install_windows.go ipn/ipnlocal: add file sharing to windows shell 2021-04-23 13:32:33 -07:00
tailscaled_notwindows.go Revert "cmd/tailscaled: split package main into main shim + package" 2021-03-25 09:06:00 -07:00
tailscaled_windows.go cmd/tailscaled: don't block ipnserver startup behind engine init on Windows 2021-04-20 22:26:27 -07:00
tailscaled.defaults cmd/tailscaled: rename relaynode reference in defaults file comment 2020-03-13 14:38:04 -07:00
tailscaled.go wgengine/magicsock: remove DefaultPort const 2021-04-28 10:39:28 -07:00
tailscaled.service cmd/tailscaled/tailscaled.service: revert recent hardening for now 2021-02-01 13:37:48 -08:00