(src *peer, rfhs []*proto.CoordinateRequest_ReadyForHandshake)
| 301 | } |
| 302 | |
| 303 | func (c *core) handleReadyForHandshakeLocked(src *peer, rfhs []*proto.CoordinateRequest_ReadyForHandshake) error { |
| 304 | for _, rfh := range rfhs { |
| 305 | dstID, err := uuid.FromBytes(rfh.Id) |
| 306 | if err != nil { |
| 307 | // this shouldn't happen unless there is a client error. Close the connection so the client |
| 308 | // doesn't just happily continue thinking everything is fine. |
| 309 | return xerrors.Errorf("unable to convert bytes to UUID: %w", err) |
| 310 | } |
| 311 | |
| 312 | if !c.tunnels.tunnelExists(src.id, dstID) { |
| 313 | // We intentionally do not return an error here, since it's |
| 314 | // inherently racy. It's possible for a source to connect, then |
| 315 | // subsequently disconnect before the agent has sent back the RFH. |
| 316 | // Since this could potentially happen to a non-malicious agent, we |
| 317 | // don't want to kill its connection. |
| 318 | select { |
| 319 | case src.resps <- &proto.CoordinateResponse{ |
| 320 | Error: fmt.Sprintf("%s: you do not share a tunnel with %q", ReadyForHandshakeError, dstID.String()), |
| 321 | }: |
| 322 | default: |
| 323 | return ErrWouldBlock |
| 324 | } |
| 325 | continue |
| 326 | } |
| 327 | |
| 328 | dst, ok := c.peers[dstID] |
| 329 | if ok { |
| 330 | select { |
| 331 | case dst.resps <- &proto.CoordinateResponse{ |
| 332 | PeerUpdates: []*proto.CoordinateResponse_PeerUpdate{{ |
| 333 | Id: src.id[:], |
| 334 | Kind: proto.CoordinateResponse_PeerUpdate_READY_FOR_HANDSHAKE, |
| 335 | }}, |
| 336 | }: |
| 337 | default: |
| 338 | return ErrWouldBlock |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | return nil |
| 343 | } |
| 344 | |
| 345 | func (c *core) nodeUpdateLocked(p *peer, node *proto.Node) (err error) { |
| 346 | c.logger.Debug(context.Background(), "processing node update", |
no test coverage detected