mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-26 03:25:35 +00:00
wgengine/magicsock: don't check always-non-nil endpoint for nil-ness
Continuation of 2aa5df7ac1
, 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>
This commit is contained in:
parent
e7eb46bced
commit
11fdb14c53
@ -128,7 +128,7 @@ func (m *peerMap) endpointForNodeKey(nk tailcfg.NodeKey) (ep *endpoint, ok bool)
|
||||
if nk.IsZero() {
|
||||
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 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
|
||||
// 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) {
|
||||
if info, ok := m.byIPPort[ipp]; ok && info.ep != nil {
|
||||
if info, ok := m.byIPPort[ipp]; ok {
|
||||
return info.ep, true
|
||||
}
|
||||
return nil, false
|
||||
@ -146,11 +146,9 @@ func (m *peerMap) endpointForIPPort(ipp netaddr.IPPort) (ep *endpoint, ok bool)
|
||||
// forEachEndpoint invokes f on every endpoint in m.
|
||||
func (m *peerMap) forEachEndpoint(f func(ep *endpoint)) {
|
||||
for _, pi := range m.byNodeKey {
|
||||
if pi.ep != nil {
|
||||
f(pi.ep)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// forEachEndpointWithDiscoKey invokes f on every endpoint in m
|
||||
// that has the provided DiscoKey.
|
||||
@ -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
|
||||
// over that instead.
|
||||
for _, pi := range m.byNodeKey {
|
||||
if pi.ep != nil && pi.ep.discoKey == dk {
|
||||
if pi.ep.discoKey == dk {
|
||||
f(pi.ep)
|
||||
}
|
||||
}
|
||||
@ -175,7 +173,7 @@ func (m *peerMap) upsertEndpoint(ep *endpoint) {
|
||||
} else {
|
||||
old := pi.ep
|
||||
pi.ep = ep
|
||||
if old != nil && old.discoKey != ep.discoKey {
|
||||
if old.discoKey != ep.discoKey {
|
||||
delete(m.byDiscoKey, old.discoKey)
|
||||
delete(m.nodesOfDisco[old.discoKey], ep.publicKey)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user