mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-08 22:12:21 +00:00
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
@@ -1395,16 +1395,7 @@ func (c *Conn) findEndpoint(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)
|
||||
return c.findLegacyEndpointLocked(ipp, addr)
|
||||
}
|
||||
|
||||
type udpReadResult struct {
|
||||
@@ -2476,23 +2467,20 @@ func (c *Conn) Rebind() {
|
||||
if haveKey {
|
||||
c.goDerpConnect(c.myDerp)
|
||||
}
|
||||
c.resetAddrSetStates()
|
||||
c.resetEndpointStates()
|
||||
}
|
||||
|
||||
// resetAddrSetStates resets the preferred address for all peers and
|
||||
// resetEndpointStates resets the preferred address for all peers and
|
||||
// re-enables spraying.
|
||||
// This is called when connectivity changes enough that we no longer
|
||||
// trust the old routes.
|
||||
func (c *Conn) resetAddrSetStates() {
|
||||
func (c *Conn) resetEndpointStates() {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
for _, as := range c.addrsByKey {
|
||||
as.curAddr = -1
|
||||
as.stopSpray = as.timeNow().Add(sprayPeriod)
|
||||
}
|
||||
for _, de := range c.endpointOfDisco {
|
||||
de.noteConnectivityChange()
|
||||
}
|
||||
c.resetAddrSetStatesLocked()
|
||||
}
|
||||
|
||||
// packIPPort packs an IPPort into the form wanted by WireGuard.
|
||||
|
||||
Reference in New Issue
Block a user