qrcode

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package qrcode generates a pairing QR code + connection info for the rmote-agent daemon. The QR encodes a JSON payload that iOS's QRScannerView parses (ServerEditView.handleQRCode): {"ip","port","token"}. Scanning it pre-fills the server profile fields (host, port, auth token) — the fastest path from "daemon installed" to "iOS connected".

The token is ALSO printed as plain text so users who can't scan a QR (terminal over SSH, no camera) can copy-paste it. This mirrors the Mac server's QR + manual-token pairing flow.

CLI entry: `rmote-agent qrcode`.

Index

Constants

View Source
const LongHelp = `` /* 399-byte string literal not displayed */
View Source
const ShortHelp = "Print a pairing QR code for iOS (host + port + secret)"

usage strings for the CLI help text. Kept here so the qrcode logic + its help description live together.

Variables

This section is empty.

Functions

func Print

func Print(w interface{ Write([]byte) (int, error) }) error

Print renders the QR + connection info to the given writer. Used by the `rmote-agent qrcode` subcommand. Prints:

  1. The QR code (Unicode half-blocks).
  2. The connection info (IP, port).
  3. The raw token (for manual copy when QR scanning isn't available).

The token is printed in full — the user is already authenticated on the host (they ran the command), and the token is only useful for pairing iOS to THIS daemon. Printing it is the explicit purpose of the command.

Types

type Payload

type Payload struct {
	IP    string `json:"ip"`
	Port  int    `json:"port"`
	Token string `json:"token"`
}

Payload is the JSON shape iOS's QRScannerView expects. Field names match ServerEditView.handleQRCode (ios/Views/ServerEditView.swift:500-525):

ip    — the host's LAN IP (or Tailscale IP if that's all that's up)
port  — the daemon's listen port (17783)
token — the 64-hex-char bearer from ~/.rmote/agent/secret

func Generate

func Generate() (qr string, payload Payload, err error)

Generate reads the daemon secret + detects the host's primary LAN IP, builds the pairing payload, and renders a terminal QR code. Returns the QR string, the payload (for display), or an error if the secret can't be read or no usable IP is found.

The QR uses Unicode half-block characters (▀▄█) for compactness — fits in ~45 terminal columns. Quiet-zone padding is included by the library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL