pairing

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pairing handles mobile device pairing via QR codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleTerminalQR

func SimpleTerminalQR(data string) string

SimpleTerminalQR generates a simple ASCII QR representation. This is a fallback if the QR library isn't available.

Types

type PairingInfo

type PairingInfo struct {
	WebSocket string `json:"ws"`
	HTTP      string `json:"http"`
	SessionID string `json:"session"`
	Token     string `json:"token,omitempty"`
	RepoName  string `json:"repo"`
}

PairingInfo contains the information encoded in the QR code.

type QRGenerator

type QRGenerator struct {
	// contains filtered or unexported fields
}

QRGenerator generates QR codes for mobile pairing.

func NewQRGenerator

func NewQRGenerator(host string, port int, sessionID, repoName string) *QRGenerator

NewQRGenerator creates a new QR code generator.

func (*QRGenerator) GenerateJSON

func (g *QRGenerator) GenerateJSON() (string, error)

GenerateJSON returns the pairing info as JSON.

func (*QRGenerator) GeneratePNG

func (g *QRGenerator) GeneratePNG(size int) ([]byte, error)

GeneratePNG generates a PNG image of the QR code.

func (*QRGenerator) GenerateTerminal

func (g *QRGenerator) GenerateTerminal() (string, error)

GenerateTerminal generates a QR code for terminal display.

func (*QRGenerator) GetPairingInfo

func (g *QRGenerator) GetPairingInfo() *PairingInfo

GetPairingInfo returns the pairing information. If external URL is set, it's used instead of local host:port URL. WebSocket URL is derived from HTTP URL (scheme conversion + /ws path).

func (*QRGenerator) PrintToTerminal

func (g *QRGenerator) PrintToTerminal()

PrintToTerminal prints the QR code to the terminal with a border.

func (*QRGenerator) SetExternalURL

func (g *QRGenerator) SetExternalURL(externalURL string)

SetExternalURL sets the external/public URL for port forwarding scenarios. When set, this URL is used in the QR code instead of the local host:port URL. WebSocket URL is auto-derived (https→wss, append /ws).

func (*QRGenerator) SetRequireSecureTransport

func (g *QRGenerator) SetRequireSecureTransport(secure bool)

SetRequireSecureTransport controls whether generated URLs use secure schemes for non-localhost hosts.

func (*QRGenerator) SetToken

func (g *QRGenerator) SetToken(token string)

SetToken sets the pairing token.

Jump to

Keyboard shortcuts

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