mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 22:15:51 +00:00
wgengine/magicsock: move temporary endpoint lookup later, add TODO to remove
Updates #3088 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
36a07089ee
commit
e5779f019e
@ -1772,18 +1772,12 @@ func (c *Conn) handleDiscoMessage(msg []byte, src netaddr.IPPort, derpNodeSrc ke
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ep, ok := c.peerMap.endpointForDiscoKey(sender)
|
if !c.peerMap.anyEndpointForDiscoKey(sender) {
|
||||||
if !ok {
|
|
||||||
if debugDisco {
|
if debugDisco {
|
||||||
c.logf("magicsock: disco: ignoring disco-looking frame, don't know endpoint for %v", sender.ShortString())
|
c.logf("magicsock: disco: ignoring disco-looking frame, don't know endpoint for %v", sender.ShortString())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !ep.canP2P() {
|
|
||||||
// This endpoint allegedly sent us a disco packet, but we know
|
|
||||||
// they can't speak disco. Drop.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're now reasonably sure we're expecting communication from
|
// We're now reasonably sure we're expecting communication from
|
||||||
// this peer, do the heavy crypto lifting to see what they want.
|
// this peer, do the heavy crypto lifting to see what they want.
|
||||||
@ -1824,6 +1818,20 @@ func (c *Conn) handleDiscoMessage(msg []byte, src netaddr.IPPort, derpNodeSrc ke
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(bradfitz): remove this endpointForDiscoKey lookup once handlePingLocked
|
||||||
|
// and handlePongConnLocked are updated to look up the endpoint on their own
|
||||||
|
// different ways (not by DiscoKey).
|
||||||
|
ep, ok := c.peerMap.endpointForDiscoKey(sender)
|
||||||
|
if !ok {
|
||||||
|
// Shouldn't be possible if anyEndpointForDiscoKey above passed.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !ep.canP2P() {
|
||||||
|
// This endpoint allegedly sent us a disco packet, but we know
|
||||||
|
// they can't speak disco. Drop.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
switch dm := dm.(type) {
|
switch dm := dm.(type) {
|
||||||
case *disco.Ping:
|
case *disco.Ping:
|
||||||
c.handlePingLocked(dm, ep, src, sender)
|
c.handlePingLocked(dm, ep, src, sender)
|
||||||
|
Loading…
Reference in New Issue
Block a user