@ -137,8 +137,8 @@ func (m *peerMap) endpointForIPPort(ipp netaddr.IPPort) (ep *endpoint, ok bool)
return nil , false
return nil , false
}
}
// forEach Disco Endpoint invokes f on every endpoint in m.
// forEach Endpoint invokes f on every endpoint in m.
func ( m * peerMap ) forEach Disco Endpoint( f func ( ep * endpoint ) ) {
func ( m * peerMap ) forEach Endpoint( 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
}
}
}
}
// upsert Disco Endpoint stores endpoint in the peerInfo for
// upsert Endpoint 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 ) upsert Disco Endpoint( ep * endpoint ) {
func ( m * peerMap ) upsert Endpoint( 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)
}
}
}
}
// delete Disco Endpoint deletes the peerInfo associated with ep, and
// delete Endpoint deletes the peerInfo associated with ep, and
// updates indexes.
// updates indexes.
func ( m * peerMap ) delete Disco Endpoint( ep * endpoint ) {
func ( m * peerMap ) delete Endpoint( 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 . forEach Disco Endpoint( func ( ep * endpoint ) {
c . peerMap . forEach Endpoint( 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 . upsert Disco Endpoint( ep ) // maybe update discokey mappings in peerMap
c . peerMap . upsert Endpoint( 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 . upsert Disco Endpoint( ep )
c . peerMap . upsert Endpoint( 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 . forEach Disco Endpoint( func ( ep * endpoint ) {
c . peerMap . forEach Endpoint( func ( ep * endpoint ) {
if ! keep [ ep . publicKey ] {
if ! keep [ ep . publicKey ] {
c . peerMap . delete Disco Endpoint( ep )
c . peerMap . delete Endpoint( ep )
}
}
} )
} )
}
}
@ -2434,7 +2434,7 @@ func (c *Conn) Close() error {
c . stopPeriodicReSTUNTimerLocked ( )
c . stopPeriodicReSTUNTimerLocked ( )
c . portMapper . Close ( )
c . portMapper . Close ( )
c . peerMap . forEach Disco Endpoint( func ( ep * endpoint ) {
c . peerMap . forEach Endpoint( 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 . forEach Disco Endpoint( func ( ep * endpoint ) {
c . peerMap . forEach Endpoint( 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 . forEach Disco Endpoint( func ( ep * endpoint ) {
c . peerMap . forEach Endpoint( 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 )