wgengine/magicsock: fix crash introduced in recent cleanups

Fixes #2801

Signed-off-by: Brad Fitzpatrick <[email protected]>
This commit is contained in:
Brad Fitzpatrick authored and Brad Fitzpatrick committed 2021-09-08 08:27:51 -07:00
1 parent 640134421e
commit 2238814b99
1 file changed
+6 -1
+6 -1
View File
@@ -189,9 +189,14 @@ func (m *peerMap) deleteDiscoEndpoint(ep *endpoint) {
return
}
ep.stopAndReset()
pi := m.byDiscoKey[ep.discoKey]
pi := m.byNodeKey[ep.publicKey]
delete(m.byDiscoKey, ep.discoKey)
delete(m.byNodeKey, ep.publicKey)
if pi == nil {
// Kneejerk paranoia from earlier issue 2801.
// Unexpected. But no logger plumbed here to log so.
return
}
for ip := range pi.ipPorts {
delete(m.byIPPort, ip)
}