tailscale/cmd
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
..
cloner all: adjust Unix permissions for those without umasks 2021-01-11 19:24:41 -08:00
derper cmd/derper: add /bootstrap-dns handler 2021-02-26 09:29:28 -08:00
hello client/tailscale/apitype: move local API types to new apitype package 2021-04-13 08:13:46 -07:00
microproxy cmd/microproxy: add -insecure flag 2020-09-15 15:07:56 -07:00
mkpkg cmd/mkpkg: support adding empty directories. 2020-05-04 17:57:13 -04:00
tailscale cmd/tailscale: improve file cp error message in macOS GUI version 2021-04-28 08:35:55 -07:00
tailscaled wgengine/magicsock: unify initial bind and rebind 2021-04-28 10:39:28 -07:00
tsshd net/interfaces: remove IsTailscaleIP, make callers use tsaddr. 2021-01-26 15:10:51 -08:00