Documentation
¶
Overview ¶
Package pairing handles mobile device pairing via QR codes.
Index ¶
- func SimpleTerminalQR(data string) string
- type PairingInfo
- type QRGenerator
- func (g *QRGenerator) GenerateJSON() (string, error)
- func (g *QRGenerator) GeneratePNG(size int) ([]byte, error)
- func (g *QRGenerator) GenerateTerminal() (string, error)
- func (g *QRGenerator) GetPairingInfo() *PairingInfo
- func (g *QRGenerator) PrintToTerminal()
- func (g *QRGenerator) SetExternalURL(externalURL string)
- func (g *QRGenerator) SetRequireSecureTransport(secure bool)
- func (g *QRGenerator) SetToken(token string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SimpleTerminalQR ¶
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.