Skip to content

[Hackathon] feat(tunnel): make --local runs work behind an HTTP proxy #434

Closed as not planned

Description

@Andy00L

Verified against (commit SHA or released version)

commit 988c035 (v0.14.0)

Discord Username / User ID

interferon0

What does this improvement do?

On a network whose only way out is an HTTP proxy, test run --local and tunnel start cannot work today. The CLI sends its API calls through HTTPS_PROXY, and the tunnel's control WebSocket goes through the same agent. The tunnel's data connection does not: it dials data.tun.testsprite.com:443 directly. On such a network that dial fails, the client retries for 60 seconds, and the command exits 10. The run is cancelled with advice about TLS interception, the system clock and port 443, none of which applies. The connect-timeout error even says "An HTTP proxy does not help here".

Reproduced with tunnel start against a local stand-in for the tunnel service whose data host does not resolve, so a CONNECT proxy is the only route to it (HTTPS_PROXY set, as on a locked-down corporate laptop or CI runner):

[tunnel] Tunnel t1 disconnected: getaddrinfo ENOTFOUND data.tunnel.test
... (20 times)
Error: The tunnel's encrypted data connection to data.tunnel.test:443 could not be established for 60s (last error: getaddrinfo ENOTFOUND data.tunnel.test). Corporate TLS interception, a wrong system clock, or a firewall blocking port 443 are the usual causes; ...

The proxy never saw a single CONNECT.

Details / implementation notes

Proposed:

  • When the CLI's proxy agent is active, the TLS data connection opens an HTTP CONNECT tunnel to the data-plane host through the proxy and runs its TLS handshake inside it. Certificate verification and SNI still name the tunnel server, so the proxy relays only encrypted bytes and never sees the tunnel secret.
  • The proxy is chosen with the rules undici already applies to API traffic: https_proxy/HTTPS_PROXY, then http_proxy/HTTP_PROXY, with NO_PROXY exemptions. user:password@ credentials become Proxy-Authorization: Basic.
  • The CONNECT exchange uses undici's Client.connect (already a dependency), not a hand-written HTTP parser.
  • stderr names the proxy once (host and port, never credentials). A refused CONNECT names the proxy and the HTTP status, and the final error points at the proxy settings instead of the TLS trust store.
  • The vendored tunnel client gets one optional option (dataPlaneStream) documented as a numbered delta in VENDOR.md. Without it, the dial is unchanged.
  • Out of scope: SOCKS proxies and the legacy plaintext transport keep a direct connection, and stderr says so.

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. added
    needs-triage
    hackathon
    on Oct 16, 2026
  2. fyZhang66 commented on Oct 20, 2026

    @fyZhang66
    Contributor

    Thanks — the analysis is right: the control WebSocket honours HTTPS_PROXY but the data connection dials data.tun.testsprite.com:443 directly. Supporting a proxy there is a change to the tunnel service and the tunnel client protocol together, not something that can land in this repo alone, so we're taking it on our side and tracking it internally. Closing here; we'll note it in the changelog when it ships.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hackathonneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions