Skip to content

[FEATURE]: WireGuard mesh pairing for remote devices (beyond localhost) #59393

Closed as not planned

Description

@suse-coder

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

Extend OpenCode v2 pairing beyond localhost-only tunnels with a WireGuard mesh. opencode pair should print a QR code in the terminal; scanning it from a phone, tablet, or another machine joins that device to the mesh so sessions work across networks.

Problem

Pairing/tunnels currently only work on the same machine (localhost). That blocks:

  • Phone as a remote control / monitor for a dev session
  • Laptop ↔ desktop across different networks
  • Collaboration when devices are not on the same LAN

Proposed solution

Add a WireGuard mesh under the existing session/sync protocol. Upper layers keep talking over a private mesh IP instead of localhost.

Flow

  1. opencode pair generates a host WireGuard identity (keypair + peer config: endpoint, pubkey, allowed IPs, PSK).
  2. Encode it as a pairing URI (e.g. wg://… or a compact signed payload).
  3. Render a QR code in the terminal (ASCII/Unicode) plus a pasteable join command.
  4. The other device scans / imports:
    • Mobile: deep-link into WireGuard (or an OpenCode companion) and connect
    • Desktop/CLI: opencode join <uri> or import into wg-quick / userspace WG
    • Browser: v1 fallback (relay / WebRTC data channel) if native WG isn’t available
  5. Peer gets a mesh IP (e.g. 10.88.0.2). OpenCode session/sync runs over the tunnel.

Example UX

$ opencode pair
Generating mesh identity...
Scan this QR with your device:

█▀▀▀▀▀█ ▀▄█▀▄ █▀▀▀▀▀█
█ ███ █ ▀█ ▄▀ █ ███ █
█ ▀▀▀ █ █▄▀ ▀ █ ▀▀▀ █
▀▀▀▀▀▀▀ █▄▀ █ ▀▀▀▀▀▀▀

Or: opencode join wg://eyJwdWJrZXkiOi...
Waiting for peer... (expires in 5:00)
✔ Device "iPhone-14" joined (10.88.0.2)

Requirements

  • Terminal QR (no image file)
  • Ephemeral keys per pairing; optional persist for a trusted-device list
  • Single-use QR, short TTL (e.g. 5 min)
  • NAT traversal: STUN + lightweight relay (DERP-style) when holepunching fails
  • Device list + revoke (opencode devices list / revoke <id>)
  • Signed pairing payload; don’t log private keys
  • Fallback when kernel WG isn’t available (userspace WG, or documented relay path)

Clients

Surface Approach
CLI / desktop wg-quick or embedded userspace WG (wireguard-go / similar)
Mobile Deep-link official WireGuard app first; companion app later if UX needs it
Browser Don’t block v1 on WASM-WG; use relay/WebRTC until native WG is realistic

Open questions

  1. Own relay vs. existing DERP-like service for NAT?
  2. Official WireGuard app deep-link vs. a first-party mobile app for v1?
  3. Does “browser pairing” need to be a full mesh peer, or just a secure tunnel to the host?
  4. Does joining the mesh imply trust, or is there a second auth step after connect?

Activity

  1. opencode-agent commented on Oct 26, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed proposal, @suse-coder! As I understand it, you'd like opencode pair to set up a WireGuard mesh. You'd scan a QR code from the terminal to join a phone or another machine, with NAT traversal and a relay fallback, plus opencode devices list / revoke to manage trusted devices. That way sessions would work across networks, not just on the same machine. Maintainers will consider it.

    Pairing isn't limited to localhost today, though:

    • opencode pair lists your LAN addresses, using one-time pairing codes that expire after 5 minutes.
    • opencode pair --remote (v2.0.25 and later) exposes your server through a tunnel so another device can reach it from a different network.
    • If you already run WireGuard or Tailscale yourself, opencode pair --url http://<mesh-ip>:<port> puts that address in the pairing link.

    So the new part of this request is a built-in WireGuard mesh: NAT traversal, a relay, and a list of trusted devices you can revoke.

    Related issues:

  2. neriousy commented on Nov 12, 2026

    @neriousy
    Member

    Thanks for the suggestion. This isn't something we plan to build, so closing to keep the tracker focused.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions