mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 23:07:44 +00:00
wgengine/magicsock: don't check always-non-nil endpoint for nil-ness
Continuation of 2aa5df7ac1d6cf35f91966644b78a81eb3b7d154, remove nil check because it can never be nil. (It previously was able to be nil.) Change-Id: I59cd9ad611dbdcbfba680ed9b22e841b00c9d5e6 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> (cherry picked from commit 11fdb14c5355e6ad49daa70c62180d86b546ad0a)
This commit is contained in:
parent
89739e077c
commit
b9983e6eb8
@ -128,7 +128,7 @@ func (m *peerMap) endpointForNodeKey(nk tailcfg.NodeKey) (ep *endpoint, ok bool)
|
|||||||
if nk.IsZero() {
|
if nk.IsZero() {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
if info, ok := m.byNodeKey[nk]; ok && info.ep != nil {
|
if info, ok := m.byNodeKey[nk]; ok {
|
||||||
return info.ep, true
|
return info.ep, true
|
||||||
}
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
@ -137,7 +137,7 @@ func (m *peerMap) endpointForNodeKey(nk tailcfg.NodeKey) (ep *endpoint, ok bool)
|
|||||||
// endpointForIPPort returns the endpoint for the peer we
|
// endpointForIPPort returns the endpoint for the peer we
|
||||||
// believe to be at ipp, or nil if we don't know of any such peer.
|
// believe to be at ipp, or nil if we don't know of any such peer.
|
||||||
func (m *peerMap) endpointForIPPort(ipp netaddr.IPPort) (ep *endpoint, ok bool) {
|
func (m *peerMap) endpointForIPPort(ipp netaddr.IPPort) (ep *endpoint, ok bool) {
|
||||||
if info, ok := m.byIPPort[ipp]; ok && info.ep != nil {
|
if info, ok := m.byIPPort[ipp]; ok {
|
||||||
return info.ep, true
|
return info.ep, true
|
||||||
}
|
}
|
||||||
return nil, false
|
return nil, false
|
||||||
@ -146,9 +146,7 @@ func (m *peerMap) endpointForIPPort(ipp netaddr.IPPort) (ep *endpoint, ok bool)
|
|||||||
// forEachEndpoint invokes f on every endpoint in m.
|
// forEachEndpoint invokes f on every endpoint in m.
|
||||||
func (m *peerMap) forEachEndpoint(f func(ep *endpoint)) {
|
func (m *peerMap) forEachEndpoint(f func(ep *endpoint)) {
|
||||||
for _, pi := range m.byNodeKey {
|
for _, pi := range m.byNodeKey {
|
||||||
if pi.ep != nil {
|
f(pi.ep)
|
||||||
f(pi.ep)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +156,7 @@ func (m *peerMap) forEachEndpointWithDiscoKey(dk tailcfg.DiscoKey, f func(ep *en
|
|||||||
// TODO(bradfitz): once byDiscoKey is a set of endpoints, then range
|
// TODO(bradfitz): once byDiscoKey is a set of endpoints, then range
|
||||||
// over that instead.
|
// over that instead.
|
||||||
for _, pi := range m.byNodeKey {
|
for _, pi := range m.byNodeKey {
|
||||||
if pi.ep != nil && pi.ep.discoKey == dk {
|
if pi.ep.discoKey == dk {
|
||||||
f(pi.ep)
|
f(pi.ep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +173,7 @@ func (m *peerMap) upsertEndpoint(ep *endpoint) {
|
|||||||
} else {
|
} else {
|
||||||
old := pi.ep
|
old := pi.ep
|
||||||
pi.ep = ep
|
pi.ep = ep
|
||||||
if old != nil && old.discoKey != ep.discoKey {
|
if old.discoKey != ep.discoKey {
|
||||||
delete(m.byDiscoKey, old.discoKey)
|
delete(m.byDiscoKey, old.discoKey)
|
||||||
delete(m.nodesOfDisco[old.discoKey], ep.publicKey)
|
delete(m.nodesOfDisco[old.discoKey], ep.publicKey)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user