Skip to content

[bedtime-architecture] Deepen named tunnel addressing#10

Closed
mmkal wants to merge 4 commits into
mainfrom
mmkal/26/05/19/bedtime-architecture-tunnel-addressing
Closed

[bedtime-architecture] Deepen named tunnel addressing#10
mmkal wants to merge 4 commits into
mainfrom
mmkal/26/05/19/bedtime-architecture-tunnel-addressing

Conversation

@mmkal
Copy link
Copy Markdown
Contributor

@mmkal mmkal commented May 19, 2026

Summary

This architecture PR centralizes Captun's named tunnel addressing rules in src/tunnel-addressing.ts.

The CLI, Worker route parsing, and E2E URL helpers now share the same folder-vs-subdomain classifier and the same public/connect URL builders. That removes the duplicated URL logic that tonight's cookie-selector work had already exposed as drift-prone.

Design Choice

Chosen candidate: Named Tunnel Addressing.

The important choice is that URL construction now follows the Worker router's classification, including concrete custom subdomain hosts. That keeps folder hosts such as captun.account.workers.dev on /<name> routes, while subdomain hosts such as my-test.my-tunnels.com use the host root for public and connect URLs.

Captun's current Worker router does not support path-prefixed server routes because it treats the first path segment as the tunnel name. The shared addressing API now fails fast for path-prefixed server URLs and route patterns instead of generating connect URLs that cannot attach to a tunnel.

Verification

  • Architecture branch: pnpm run typecheck
  • Architecture branch: pnpm test
  • Replacement branches were checked with the relevant old-PR checks plus architecture typecheck/tests; conflicts were resolved only where the architecture module replaced duplicated routing classification.

Replacement Branches

Existing PR Replacement compare Strategy
#3 mmkal/26/05/19/runtime-adapters comparison cherry-picked PR commits because the original base is divergent; verified with pnpm install, pnpm run build, pnpm run typecheck, pnpm test, and pnpm --filter @captun/cloudflare-example test
#4 fix/server-session-undefined-hook-on-abort comparison clean merge; verified with pnpm run typecheck and pnpm test
#5 mmkal/26/05/19/add-oxlint-oxfmt comparison merge plus formatter fix for the new architecture test block; verified with pnpm install, pnpm run check, and pnpm test
#6 mmkal/26/05/19/cookie-rooted-folder-tunnels comparison small routing conflict resolved by keeping cookie routing and importing the shared classifier; verified with pnpm run typecheck and pnpm test
#7 mmkal/26/05/19/browser-demo-page comparison clean merge; verified with node --check docs/browser-demo.js, node --check docs/browser-demo-client.js, pnpm run typecheck, and pnpm test
#8 mmkal/26/05/19/browser-demo-handler-sandbox comparison clean merge; verified with node --check docs/browser-demo.js, node --check docs/browser-demo-client.js, node --check docs/browser-demo-handler-worker.js, pnpm run typecheck, and pnpm test
#9 mmkal/26/05/19/cookie-selector-affordance comparison small routing conflict resolved by pointing selector URL helpers at src/tunnel-addressing.ts; verified with pnpm run typecheck and pnpm test

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 19, 2026

Open in StackBlitz

npm i https://pkg.pr.new/iterate/captun@10

commit: 953de11

@mmkal mmkal closed this May 20, 2026
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.

1 participant