DialContext dials the address provided in the workspace agent. The network must be "tcp" or "udp".
(ctx context.Context, network string, addr string)
| 351 | // DialContext dials the address provided in the workspace agent. |
| 352 | // The network must be "tcp" or "udp". |
| 353 | func (c *agentConn) DialContext(ctx context.Context, network string, addr string) (net.Conn, error) { |
| 354 | ctx, span := tracing.StartSpan(ctx) |
| 355 | defer span.End() |
| 356 | |
| 357 | if !c.AwaitReachable(ctx) { |
| 358 | return nil, xerrors.Errorf("workspace agent not reachable in time: %v", ctx.Err()) |
| 359 | } |
| 360 | |
| 361 | _, rawPort, _ := net.SplitHostPort(addr) |
| 362 | port, _ := strconv.ParseUint(rawPort, 10, 16) |
| 363 | ipp := netip.AddrPortFrom(c.agentAddress(), uint16(port)) |
| 364 | |
| 365 | switch network { |
| 366 | case "tcp": |
| 367 | return c.Conn.DialContextTCP(ctx, ipp) |
| 368 | case "udp": |
| 369 | return c.Conn.DialContextUDP(ctx, ipp) |
| 370 | default: |
| 371 | return nil, xerrors.Errorf("unknown network %q", network) |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | // AppHTTPClient returns an HTTP client for reaching HTTP apps served by this |
| 376 | // workspace agent. Redirects are blocked to prevent misuse. |
nothing calls this directly
no test coverage detected