Skip to content

Route local HTTP shares through the Sandbox wildcard edge - #7

Merged
bas3line merged 8 commits into
mainfrom
feat/http-share
Jul 19, 2026
Merged

Route local HTTP shares through the Sandbox wildcard edge#7
bas3line merged 8 commits into
mainfrom
feat/http-share

Conversation

@bas3line

@bas3line bas3line commented Jul 19, 2026

Copy link
Copy Markdown
Owner

What changed

  • replaces the third-party quick-tunnel fallback with a first-party relay at relay.tunnel.yshubham.com
  • creates ephemeral exact-host routes below *.tunnel.yshubham.com
  • proxies HTTP and WebSocket traffic over one outbound CLI connection, including Vite HMR
  • detects the active IPv4 (127.0.0.1) or IPv6 (::1) loopback listener and forwards to that exact address
  • rewrites the upstream Host and Origin to loopback so Vite does not need server.allowedHosts changes
  • adds relay limits, TTL cleanup, authentication controls, Compose route-volume initialization, Caddy routing, and self-hosting documentation
  • bumps the release to v0.1.5

Root causes

The initial shortcut launched localhost.run or Cloudflare Quick Tunnels directly from the CLI. That bypassed the Sandbox edge and produced unrelated public domains such as *.lhr.life, which Vite correctly rejected as an untrusted Host.

The first hosted-relay release detected both IPv4 and IPv6 listeners but forwarded every local request to 127.0.0.1. Frameworks such as Astro can bind only to ::1, which made the public edge return 502 even though the listener preflight succeeded.

User impact

sandbox http 4321 now returns https://local-<random>.tunnel.yshubham.com and works with services bound to either loopback family. Ctrl-C removes the route immediately. Self-hosted deployments can use SANDBOX_HTTP_RELAY or --relay.

Validation

  • cargo test --locked --workspace --all-targets
  • cargo clippy --locked --workspace --all-targets -- -D warnings
  • GitHub rust and supply-chain checks
  • real IPv6-only Astro/Vite page through the public Cloudflare and Origin CA path: HTTP 200, no blocked Host response
  • real Vite HMR over public wss://: received {"type":"connected"}
  • route revocation: public hostname returned 404 immediately after Ctrl-C
  • installed v0.1.5 macOS ARM64 binary completed the public IPv6 relay test
  • public v0.1.5 installers verified on macOS ARM64 and Linux x86-64

@bas3line
bas3line marked this pull request as ready for review July 19, 2026 18:12
Copilot AI review requested due to automatic review settings July 19, 2026 18:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes — adds sandbox http PORT as a guarded shortcut over sandbox tunnel create, with automatic sandbox selection, capability gating, and active-tunnel reuse.

  • New HttpArgs struct and run_http function — resolves the target sandbox from SANDBOX_ID/--sandbox, or the tenant's only running sandbox; gates on /healthz tunnel capabilities; reuses an existing active tunnel for the same port; falls through to run_tunnel for new tunnels.
  • New helpersvalidate_http_capabilities, select_only_running_sandbox, select_only_sandbox_id, and parse_port with unit test coverage.
  • Version bump 0.1.10.1.2 across Cargo.toml, Cargo.lock, and deployment docs.
  • Documentation updated in README.md, docs/cli.md, and the agent skill reference.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro𝕏

Comment thread cmd/sandbox/src/main.rs Outdated
@bas3line bas3line changed the title Add guarded sandbox http sharing shortcut Share local HTTP ports with one command Jul 19, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — rewrites run_http from a controller-mediated shortcut into a direct local sharing path that launches a subprocess tunnel (cloudflared or SSH) and scans its output for the public URL.

  • Direct local sharing in run_http — checks the port is listening on local IPv4/IPv6, resolves a tunnel provider (cloudflared auto-preferred, fallback to ssh), spawns the helper subprocess, scans stdout/stderr for the HTTPS URL with host-based validation, prints it, and blocks on Ctrl-C.
  • New HttpProvider enum and supporting infrastructureresolve_http_provider, find_executable, find_ssh, provider_command, public_url_in_line, provider_name, alternative_provider with unit test coverage for CLI parsing, URL extraction, and listener detection.
  • Removed controller-mediated pathvalidate_http_capabilities, select_only_running_sandbox, select_only_sandbox_id, and the SandboxClient parameter from run_http are all gone; managed tunnels remain accessible via sandbox tunnel create.
  • Version 0.1.1 → 0.1.3 around the unreleased 0.1.2 — workspace version, lockfile, and deployment docs.
  • Documentation updated in README.md, docs/cli.md, and the agent skill reference to describe the new local-sharing semantics.

Pullfrog  | View workflow run | Using DeepSeek Pro𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes — replaces the standalone cloudflared/SSH local tunnel with a custom WebSocket relay through the Sandbox controller edge.

  • New local_http client module — connects to the relay via WebSocket, receives proxied HTTP/WebSocket requests as JSON messages, forwards to 127.0.0.1:PORT, and sends responses back through the same channel.
  • New local_relay server module — accepts WebSocket connections at /v1/local-tunnels/connect, manages an in-memory session registry, writes dynamic edge routes via NamedTempFile + persist, and proxies inbound HTTP/WebSocket traffic.
  • New protocol types in sandbox_core::apiLocalRelayServerMessage, LocalRelayClientMessage, and RelayWebSocketFrame with serde-tagged serialization.
  • New TunnelConfig fieldslocal_relay_enabled, local_relay_require_auth, local_relay_upstream, max_local_relays, max_local_relays_per_client, local_relay_body_limit_bytes, local_relay_ttl_seconds with bounded validation.
  • CLI args restructured--provider replaced by --relay (Url, default https://relay.tunnel.yshubham.com) and --subdomain; SANDBOX_HTTP_RELAY env var replaces SANDBOX_HTTP_PROVIDER.
  • Version bumped 0.1.10.1.4 across workspace, lockfile, and deployment docs.
  • Edge and deployment config — Caddy files gain relay.<domain> routes; Compose adds tunnel-routes-init init service and shared volume; authorization endpoint recognizes relay hostnames.
  • Documentation updated in cli.md, configuration.md, security.md, tunnels.md, client.md, and the agent skill descriptor.

ℹ️ No critical issues — one stale doc reference inline.


Note: 1 inline comment(s) dropped because they did not anchor to lines inside the PR diff:

  • skills/sandbox-platform/references/cli.md:2035 (RIGHT) — line 2035 (RIGHT) is not inside a diff hunk

Pullfrog  | Fix it ➔View workflow run | Using DeepSeek Pro𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — adds explicit rustls crypto provider initialization to guard against feature inference in release builds.

  • Added rustls workspace dependency with aws_lc_rs, std, and tls12 features, wired into cmd/sandbox/Cargo.toml.
  • Installed aws_lc_rs as the process-wide default provider at the top of main() so reqwest and the WebSocket relay share one TLS backend regardless of feature resolution order.

Pullfrog  | View workflow run | Using DeepSeek Pro𝕏

@bas3line bas3line changed the title Share local HTTP ports with one command Route local HTTP shares through the Sandbox wildcard edge Jul 19, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one stale architecture reference inline.

Reviewed changes — documents the relay routing architecture across deploy configs, API and CLI docs, configuration reference, security model, tunnel guide, client setup guide, and agent skill descriptor.

  • Deploy configuration — added relay.<domain> routes to all three Caddyfile examples and the Cloudflare compose overlay.
  • API and CLI documentation — documented the /v1/local-tunnels/connect WebSocket endpoint with authentication and architecture notes; restructured CLI docs into local sharing vs. managed sandbox tunnels.
  • Configuration, security, and tunnel docs — added all eight local relay configuration keys with descriptions and operational guidance; documented relay security model and workstation sharing workflow; updated client setup guide.
  • Agent skill updates — rewrote the skill description and rule 7 to cover both sandbox http PORT and sandbox tunnel create paths.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro𝕏

sandbox http 3000
```

The command checks both local IPv4 and IPv6, prints a temporary public HTTPS URL, and stays attached until Ctrl-C. It does not require `SANDBOX_URL`. It prefers an installed `cloudflared` and falls back to the system SSH client with localhost.run. Treat the URL as public and never expose credentials, private data, or admin interfaces.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This describes the pre-relay cloudflared/SSH provider architecture from commit e929646. Since 5ee3beb the CLI connects directly to the Sandbox relay over a WebSocket — there is no cloudflared or SSH involved. The other docs (docs/cli.md, docs/tunnels.md, docs/how-to-setup/client.md, and the SKILL.md frontmatter) all correctly describe the relay. Update this paragraph to match: the CLI opens an outbound WebSocket to the relay, the controller creates a temporary route, and requests are proxied back over that channel.

Technical details
# Skill reference still describes cloudflared/SSH instead of WebSocket relay

## Affected sites
- `skills/sandbox-platform/references/cli.md:68` — says "prefers an installed cloudflared and falls back to the system SSH client with localhost.run"

## Required outcome
- Replace the cloudflared/SSH description with the WebSocket relay behavior: the CLI opens an outbound WebSocket to the relay, the controller creates a temporary exact-host route, and requests are proxied back over that channel

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues. The prior stale-doc finding at skills/sandbox-platform/references/cli.md remains open and unchanged by this commit.

Reviewed changesensure_local_listener now returns the detected SocketAddr instead of void, probes ::1 in addition to 127.0.0.1, and threads the exact address through relay_http_request, relay_local_websocket, and local_url.

  • IPv6 loopback detection and forwardingensure_local_listener probes both 127.0.0.1 and ::1 with a 500ms timeout, returning the first address that accepts a connection. IPv4 is tried first so dual-stack listeners always get 127.0.0.1. local_url now validates the URL host matches the expected IP version, and SocketAddr Display handles bracket-wrapping for IPv6 in the URL string.
  • Version bump 0.1.4 → 0.1.5 across workspace, lockfile, README.md, and custom-public-domains.md.
  • Documentation updated in docs/tunnels.md and skills/sandbox-platform/SKILL.md to mention IPv4/IPv6 loopback detection.

Pullfrog  | Fix it ➔View workflow run | Using DeepSeek Pro𝕏

@bas3line
bas3line merged commit c24c24f into main Jul 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants