wgengine/magicsock: move more legacy endpoint handling.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
committed by
Dave Anderson
parent
58fcd103c4
commit
f873da5b16
@@ -13,6 +13,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/tailscale/wireguard-go/conn"
|
||||
"github.com/tailscale/wireguard-go/device"
|
||||
"github.com/tailscale/wireguard-go/wgcfg"
|
||||
"inet.af/netaddr"
|
||||
@@ -23,6 +24,26 @@ import (
|
||||
|
||||
var errNoDestinations = errors.New("magicsock: no destinations")
|
||||
|
||||
func (c *Conn) findLegacyEndpointLocked(ipp netaddr.IPPort, addr *net.UDPAddr) conn.Endpoint {
|
||||
// Pre-disco: look up their addrSet.
|
||||
if as, ok := c.addrsByUDP[ipp]; ok {
|
||||
return as
|
||||
}
|
||||
|
||||
// Pre-disco: the peer that sent this packet has roamed beyond
|
||||
// the knowledge provided by the control server. If the
|
||||
// packet is valid wireguard will call UpdateDst on the
|
||||
// original endpoint using this addr.
|
||||
return (*singleEndpoint)(addr)
|
||||
}
|
||||
|
||||
func (c *Conn) resetAddrSetStatesLocked() {
|
||||
for _, as := range c.addrsByKey {
|
||||
as.curAddr = -1
|
||||
as.stopSpray = as.timeNow().Add(sprayPeriod)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Conn) sendSingleEndpoint(b []byte, se *singleEndpoint) error {
|
||||
addr := (*net.UDPAddr)(se)
|
||||
if addr.IP.Equal(derpMagicIP) {
|
||||
|
||||
Reference in New Issue
Block a user