(src *peer, dstID uuid.UUID)
| 369 | } |
| 370 | |
| 371 | func (c *core) addTunnelLocked(src *peer, dstID uuid.UUID) error { |
| 372 | c.tunnels.add(src.id, dstID) |
| 373 | c.logger.Debug(context.Background(), "adding tunnel", |
| 374 | slog.F("src_id", src.id), |
| 375 | slog.F("dst_id", dstID)) |
| 376 | dst, ok := c.peers[dstID] |
| 377 | if ok { |
| 378 | if dst.node != nil { |
| 379 | err := src.updateMappingLocked(dstID, dst.node, proto.CoordinateResponse_PeerUpdate_NODE, "add tunnel") |
| 380 | if err != nil { |
| 381 | src.logger.Error(context.Background(), "failed update of tunnel src", slog.Error(err)) |
| 382 | c.removePeerLocked(src.id, proto.CoordinateResponse_PeerUpdate_DISCONNECTED, "failed update", |
| 383 | "failed to update tunnel dest mapping") |
| 384 | // if the source fails, then the tunnel is also removed and there is no reason to continue |
| 385 | // processing. |
| 386 | return err |
| 387 | } |
| 388 | } |
| 389 | if src.node != nil { |
| 390 | err := dst.updateMappingLocked(src.id, src.node, proto.CoordinateResponse_PeerUpdate_NODE, "add tunnel") |
| 391 | if err != nil { |
| 392 | dst.logger.Error(context.Background(), "failed update of tunnel dst", slog.Error(err)) |
| 393 | c.removePeerLocked(dst.id, proto.CoordinateResponse_PeerUpdate_DISCONNECTED, "failed update", |
| 394 | "failed to update tunnel src mapping") |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | return nil |
| 399 | } |
| 400 | |
| 401 | func (c *core) removeTunnelLocked(src *peer, dstID uuid.UUID) error { |
| 402 | err := src.updateMappingLocked(dstID, nil, proto.CoordinateResponse_PeerUpdate_DISCONNECTED, "remove tunnel") |
no test coverage detected