Speedtest runs a speedtest against the workspace agent.
(ctx context.Context, direction speedtest.Direction, duration time.Duration)
| 327 | |
| 328 | // Speedtest runs a speedtest against the workspace agent. |
| 329 | func (c *agentConn) Speedtest(ctx context.Context, direction speedtest.Direction, duration time.Duration) ([]speedtest.Result, error) { |
| 330 | ctx, span := tracing.StartSpan(ctx) |
| 331 | defer span.End() |
| 332 | |
| 333 | if !c.AwaitReachable(ctx) { |
| 334 | return nil, xerrors.Errorf("workspace agent not reachable in time: %v", ctx.Err()) |
| 335 | } |
| 336 | |
| 337 | c.Conn.SendConnectedTelemetry(c.agentAddress(), tailnet.TelemetryApplicationSpeedtest) |
| 338 | speedConn, err := c.Conn.DialContextTCP(ctx, netip.AddrPortFrom(c.agentAddress(), AgentSpeedtestPort)) |
| 339 | if err != nil { |
| 340 | return nil, xerrors.Errorf("dial speedtest: %w", err) |
| 341 | } |
| 342 | |
| 343 | results, err := speedtest.RunClientWithConn(direction, duration, speedConn) |
| 344 | if err != nil { |
| 345 | return nil, xerrors.Errorf("run speedtest: %w", err) |
| 346 | } |
| 347 | |
| 348 | return results, err |
| 349 | } |
| 350 | |
| 351 | // DialContext dials the address provided in the workspace agent. |
| 352 | // The network must be "tcp" or "udp". |
nothing calls this directly
no test coverage detected