Skip to content

Companion tunnel: allow a self-hosted or custom relay #249

Description

@jiweiyuan

Problem

Every tunnel provider termio offers terminates on somebody else's server (trycloudflare.com, ngrok.app, tunelo.net). A user who wants their phone to reach their Mac without a third party in the path has no option but "off, LAN only". For a tool whose whole trust story is "the code never leaves hardware you control", the remote path should be self-hostable too.

Original request

ios 访问 mac 是用了服务器中转吗?中转服务是否可以开源自部署?

@higolee, v2ex/t/1232978#36

Verified state

Half of this already exists, and the question shows it is not discoverable:

  • TunnelManager (Sources/termio/Companion/TunnelManager.swift) already offers a choice of off / tunelo / cloudflared / ngrok, each a Spec with its own argv, URL pattern, and install path.
  • The tunnel is a dumb pipe: a connection arriving through it still has to present the pairing token before the companion server serves anything.
  • What is missing is a user-supplied endpoint. Provider is a closed enum with hardcoded specs, so a self-hosted cloudflared named tunnel, a self-hosted tunelo instance, or any other relay cannot be selected.

Desired outcome

A user can point the companion at a relay they run themselves. Two things, either of which is useful alone:

  1. Custom provider — a user-supplied command plus the URL pattern to scrape, following the existing Spec shape. This is the general answer and costs one enum case plus a settings form.
  2. Self-hosted endpoint for the bundled providers — a named-tunnel hostname for cloudflared, a server URL for tunelo, so the common cases don't require hand-writing argv.

Whichever lands, Settings ▸ Mobile should say plainly which providers are third-party and which are yours, so the answer to "是否可以自部署" is visible in the app rather than in a forum reply.

Open questions

  • A free-form command in settings is a code-execution surface. It is the user's own machine and their own command, but it should be explicit in the UI, not a bare text field labeled "command".
  • tunelo is ours (jiweiyuan/tunelo) — does its server support a self-hosted deployment today, or is that its own piece of work?

Contributions welcome; this is a well-bounded change in one file plus a settings form.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions