mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-23 17:18:42 +00:00
wgengine/magicsock: use derp-region-as-magic-AddrPort hack in fewer places
And fix up a bogus comment and flesh out some other comments. Updates #cleanup Change-Id: Ia60a1c04b0f5e44e8d9587914af819df8e8f442a Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
e181f12a7b
commit
9df107f4f0
@@ -7,6 +7,7 @@ package magicsock
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -1154,7 +1155,8 @@ func (c *Conn) sendAddr(addr netip.AddrPort, pubKey key.NodePublic, b []byte) (s
|
||||
return c.sendUDP(addr, b)
|
||||
}
|
||||
|
||||
ch := c.derpWriteChanOfAddr(addr, pubKey)
|
||||
regionID := int(addr.Port())
|
||||
ch := c.derpWriteChanForRegion(regionID, pubKey)
|
||||
if ch == nil {
|
||||
metricSendDERPErrorChan.Add(1)
|
||||
return false, nil
|
||||
@@ -1165,8 +1167,7 @@ func (c *Conn) sendAddr(addr netip.AddrPort, pubKey key.NodePublic, b []byte) (s
|
||||
// to derpWriteRequest and waited for derphttp.Client.Send to
|
||||
// complete, but that's too slow while holding wireguard-go
|
||||
// internal locks.
|
||||
pkt := make([]byte, len(b))
|
||||
copy(pkt, b)
|
||||
pkt := bytes.Clone(b)
|
||||
|
||||
select {
|
||||
case <-c.donec:
|
||||
|
Reference in New Issue
Block a user