mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-04 15:35:38 +00:00
wgengine/magicsock: finish some renamings of discoEndpoint to endpoint
Renames only; continuation of earlier8049063d35
These kept confusing me while working on #3088 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> (cherry picked from commit569f70abfd
)
This commit is contained in:
parent
f054e16451
commit
3e317852ce
@ -137,8 +137,8 @@ func (m *peerMap) endpointForIPPort(ipp netaddr.IPPort) (ep *endpoint, ok bool)
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// forEachDiscoEndpoint invokes f on every endpoint in m.
|
// forEachEndpoint invokes f on every endpoint in m.
|
||||||
func (m *peerMap) forEachDiscoEndpoint(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 {
|
if pi.ep != nil {
|
||||||
f(pi.ep)
|
f(pi.ep)
|
||||||
@ -158,10 +158,10 @@ func (m *peerMap) forEachEndpointWithDiscoKey(dk tailcfg.DiscoKey, f func(ep *en
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// upsertDiscoEndpoint stores endpoint in the peerInfo for
|
// upsertEndpoint stores endpoint in the peerInfo for
|
||||||
// ep.publicKey, and updates indexes. m must already have a
|
// ep.publicKey, and updates indexes. m must already have a
|
||||||
// tailcfg.Node for ep.publicKey.
|
// tailcfg.Node for ep.publicKey.
|
||||||
func (m *peerMap) upsertDiscoEndpoint(ep *endpoint) {
|
func (m *peerMap) upsertEndpoint(ep *endpoint) {
|
||||||
pi := m.byNodeKey[ep.publicKey]
|
pi := m.byNodeKey[ep.publicKey]
|
||||||
if pi == nil {
|
if pi == nil {
|
||||||
pi = newPeerInfo()
|
pi = newPeerInfo()
|
||||||
@ -189,9 +189,9 @@ func (m *peerMap) setDiscoKeyForIPPort(ipp netaddr.IPPort, dk tailcfg.DiscoKey)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteDiscoEndpoint deletes the peerInfo associated with ep, and
|
// deleteEndpoint deletes the peerInfo associated with ep, and
|
||||||
// updates indexes.
|
// updates indexes.
|
||||||
func (m *peerMap) deleteDiscoEndpoint(ep *endpoint) {
|
func (m *peerMap) deleteEndpoint(ep *endpoint) {
|
||||||
if ep == nil {
|
if ep == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2067,7 +2067,7 @@ func (c *Conn) SetPrivateKey(privateKey wgkey.Private) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if newKey.IsZero() {
|
if newKey.IsZero() {
|
||||||
c.peerMap.forEachDiscoEndpoint(func(ep *endpoint) {
|
c.peerMap.forEachEndpoint(func(ep *endpoint) {
|
||||||
ep.stopAndReset()
|
ep.stopAndReset()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -2169,7 +2169,7 @@ func (c *Conn) SetNetworkMap(nm *netmap.NetworkMap) {
|
|||||||
for _, n := range nm.Peers {
|
for _, n := range nm.Peers {
|
||||||
if ep, ok := c.peerMap.endpointForNodeKey(n.Key); ok {
|
if ep, ok := c.peerMap.endpointForNodeKey(n.Key); ok {
|
||||||
ep.updateFromNode(n)
|
ep.updateFromNode(n)
|
||||||
c.peerMap.upsertDiscoEndpoint(ep) // maybe update discokey mappings in peerMap
|
c.peerMap.upsertEndpoint(ep) // maybe update discokey mappings in peerMap
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2209,7 +2209,7 @@ func (c *Conn) SetNetworkMap(nm *netmap.NetworkMap) {
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
ep.updateFromNode(n)
|
ep.updateFromNode(n)
|
||||||
c.peerMap.upsertDiscoEndpoint(ep)
|
c.peerMap.upsertEndpoint(ep)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the set of nodes changed since the last SetNetworkMap, the
|
// If the set of nodes changed since the last SetNetworkMap, the
|
||||||
@ -2222,9 +2222,9 @@ func (c *Conn) SetNetworkMap(nm *netmap.NetworkMap) {
|
|||||||
for _, n := range nm.Peers {
|
for _, n := range nm.Peers {
|
||||||
keep[n.Key] = true
|
keep[n.Key] = true
|
||||||
}
|
}
|
||||||
c.peerMap.forEachDiscoEndpoint(func(ep *endpoint) {
|
c.peerMap.forEachEndpoint(func(ep *endpoint) {
|
||||||
if !keep[ep.publicKey] {
|
if !keep[ep.publicKey] {
|
||||||
c.peerMap.deleteDiscoEndpoint(ep)
|
c.peerMap.deleteEndpoint(ep)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -2434,7 +2434,7 @@ func (c *Conn) Close() error {
|
|||||||
c.stopPeriodicReSTUNTimerLocked()
|
c.stopPeriodicReSTUNTimerLocked()
|
||||||
c.portMapper.Close()
|
c.portMapper.Close()
|
||||||
|
|
||||||
c.peerMap.forEachDiscoEndpoint(func(ep *endpoint) {
|
c.peerMap.forEachEndpoint(func(ep *endpoint) {
|
||||||
ep.stopAndReset()
|
ep.stopAndReset()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -2688,7 +2688,7 @@ func (c *Conn) Rebind() {
|
|||||||
func (c *Conn) resetEndpointStates() {
|
func (c *Conn) resetEndpointStates() {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
c.peerMap.forEachDiscoEndpoint(func(ep *endpoint) {
|
c.peerMap.forEachEndpoint(func(ep *endpoint) {
|
||||||
ep.noteConnectivityChange()
|
ep.noteConnectivityChange()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -3001,7 +3001,7 @@ func (c *Conn) UpdateStatus(sb *ipnstate.StatusBuilder) {
|
|||||||
ss.TailAddrDeprecated = tailAddr4
|
ss.TailAddrDeprecated = tailAddr4
|
||||||
})
|
})
|
||||||
|
|
||||||
c.peerMap.forEachDiscoEndpoint(func(ep *endpoint) {
|
c.peerMap.forEachEndpoint(func(ep *endpoint) {
|
||||||
ps := &ipnstate.PeerStatus{InMagicSock: true}
|
ps := &ipnstate.PeerStatus{InMagicSock: true}
|
||||||
//ps.Addrs = append(ps.Addrs, n.Endpoints...)
|
//ps.Addrs = append(ps.Addrs, n.Endpoints...)
|
||||||
ep.populatePeerStatus(ps)
|
ep.populatePeerStatus(ps)
|
||||||
|
@ -1144,7 +1144,7 @@ func TestDiscoMessage(t *testing.T) {
|
|||||||
Key: tailcfg.NodeKey(key.NewPrivate().Public()),
|
Key: tailcfg.NodeKey(key.NewPrivate().Public()),
|
||||||
DiscoKey: peer1Pub,
|
DiscoKey: peer1Pub,
|
||||||
}
|
}
|
||||||
c.peerMap.upsertDiscoEndpoint(&endpoint{
|
c.peerMap.upsertEndpoint(&endpoint{
|
||||||
publicKey: n.Key,
|
publicKey: n.Key,
|
||||||
discoKey: n.DiscoKey,
|
discoKey: n.DiscoKey,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user