wgengine/magicsock: fix regression in initial bind for js

1f959edeb0 introduced a regression for JS
where the initial bind no longer occurred at all for JS.

The condition is moved deeper in the call tree to avoid proliferation of
higher level conditions.

Updates #5537

Signed-off-by: James Tucker <james@tailscale.com>
pull/5563/head
James Tucker 2 years ago committed by James Tucker
parent 1f959edeb0
commit be140add75

@ -2829,6 +2829,11 @@ func (c *Conn) bindSocket(ruc *RebindingUDPConn, network string, curPortFate cur
ruc.mu.Lock() ruc.mu.Lock()
defer ruc.mu.Unlock() defer ruc.mu.Unlock()
if runtime.GOOS == "js" {
ruc.setConnLocked(newBlockForeverConn())
return nil
}
if debugAlwaysDERP { if debugAlwaysDERP {
c.logf("disabled %v per TS_DEBUG_ALWAYS_USE_DERP", network) c.logf("disabled %v per TS_DEBUG_ALWAYS_USE_DERP", network)
ruc.setConnLocked(newBlockForeverConn()) ruc.setConnLocked(newBlockForeverConn())
@ -2893,9 +2898,6 @@ const (
// rebind closes and re-binds the UDP sockets. // rebind closes and re-binds the UDP sockets.
// We consider it successful if we manage to bind the IPv4 socket. // We consider it successful if we manage to bind the IPv4 socket.
func (c *Conn) rebind(curPortFate currentPortFate) error { func (c *Conn) rebind(curPortFate currentPortFate) error {
if runtime.GOOS == "js" {
return nil
}
if err := c.bindSocket(&c.pconn6, "udp6", curPortFate); err != nil { if err := c.bindSocket(&c.pconn6, "udp6", curPortFate); err != nil {
c.logf("magicsock: Rebind ignoring IPv6 bind failure: %v", err) c.logf("magicsock: Rebind ignoring IPv6 bind failure: %v", err)
} }

Loading…
Cancel
Save