updatePeers handles protocol updates about peers from the coordinator. c.L MUST NOT be held.
(updates []*proto.CoordinateResponse_PeerUpdate)
| 393 | |
| 394 | // updatePeers handles protocol updates about peers from the coordinator. c.L MUST NOT be held. |
| 395 | func (c *configMaps) updatePeers(updates []*proto.CoordinateResponse_PeerUpdate) { |
| 396 | status := c.status() |
| 397 | c.L.Lock() |
| 398 | defer c.L.Unlock() |
| 399 | |
| 400 | // Update all the lastHandshake values here. That way we don't have to |
| 401 | // worry about them being up-to-date when handling updates below, and it covers |
| 402 | // all peers, not just the ones we got updates about. |
| 403 | for _, lc := range c.peers { |
| 404 | if lc.node != nil { |
| 405 | if peerStatus, ok := status.Peer[lc.node.Key]; ok { |
| 406 | lc.lastHandshake = peerStatus.LastHandshake |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | for _, update := range updates { |
| 412 | if dirty := c.updatePeerLocked(update, status); dirty { |
| 413 | c.netmapDirty = true |
| 414 | } |
| 415 | } |
| 416 | if c.netmapDirty { |
| 417 | c.Broadcast() |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | // status requests a status update from the engine. |
| 422 | func (c *configMaps) status() *ipnstate.Status { |