hub

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hub connects clients to phones: it owns the device registry, per-device command queues, pairing, events and server-side commands.

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.1.0-dev"

Version is set at release build time with -ldflags "-X .../hub.Version=x.y.z".

Functions

func LANAddresses

func LANAddresses(port int) []string

LANAddresses lists tcp:// URLs for each private IPv4 address of this machine.

func MarshalLine

func MarshalLine(m map[string]any) []byte

MarshalLine encodes a response or event as one NDJSON line.

Types

type Call

type Call struct {
	Cmd         *spec.Command
	Params      map[string]any
	Wait        bool
	OfflineWait time.Duration
	// Late receives the final result of a command the phone answered with accepted.
	Late func(Result)
	// contains filtered or unexported fields
}

Call is one command on its way to a phone.

type Client

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

Client is one SDK, CLI, MCP or HTTP connection.

func (*Client) Close

func (c *Client) Close()

func (*Client) Exec

func (c *Client) Exec(req map[string]any) Result

Exec runs one request and waits for its response (without id).

func (*Client) Start

func (c *Client) Start(req map[string]any) <-chan Result

Start queues a request synchronously, so pipelined commands to one device keep their order, and returns a channel for the response.

type Device

type Device struct {
	ID string
	// contains filtered or unexported fields
}

func (*Device) Info

func (d *Device) Info() map[string]any

func (*Device) Name

func (d *Device) Name() string

func (*Device) Online

func (d *Device) Online() bool

func (*Device) Submit

func (d *Device) Submit(c *Call) <-chan Result

Submit queues a call in arrival order and returns where its response will land.

type Hub

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

func New

func New(o Options) (*Hub, error)

func (*Hub) AcceptAgent

func (h *Hub) AcceptAgent(conn wire.LineConn)

AcceptAgent handles one phone link until it closes.

func (*Hub) CodePairingOpen

func (h *Hub) CodePairingOpen() bool

func (*Hub) DevicePub

func (h *Hub) DevicePub(id string) (*ecdh.PublicKey, bool)

func (*Hub) EnrollToken

func (h *Hub) EnrollToken(tid string) ([]byte, bool)

func (*Hub) HTTPStatus

func (h *Hub) HTTPStatus(code string) int

HTTPStatus maps an error code to the status the local HTTP API returns.

func (*Hub) Lang

func (h *Hub) Lang() string

func (*Hub) Name

func (h *Hub) Name() string

func (*Hub) NewClient

func (h *Hub) NewClient(send func(map[string]any) error, needsAuth bool) *Client

NewClient registers a connection. needsAuth is true for non-loopback peers or when client.require_token is set.

func (*Hub) NewEnrollment

func (h *Hub) NewEnrollment(name string) (string, time.Time)

NewEnrollment creates a single-use QR token and returns the pairing URI.

func (*Hub) PendingPairs

func (h *Hub) PendingPairs() []map[string]any

PendingPairs lists phones waiting for a code, without revealing the codes.

func (*Hub) PublicKey

func (h *Hub) PublicKey() string

func (*Hub) RecoverConn

func (h *Hub) RecoverConn(kind, remote string)

RecoverConn is recoverConn for handlers outside this package.

func (*Hub) ServerID

func (h *Hub) ServerID() string

func (*Hub) SetOCRPath added in v0.1.1

func (h *Hub) SetOCRPath(path string)

SetOCRPath points OCR at a tesseract binary; tests use it to simulate a missing install.

func (*Hub) SetPorts

func (h *Hub) SetPorts(agent, client int)

func (*Hub) StaticKey

func (h *Hub) StaticKey() *ecdh.PrivateKey

func (*Hub) WebhookSecret

func (h *Hub) WebhookSecret() string

Secret returns the signing secret, creating it on first use.

type Options

type Options struct {
	Store   *store.Store
	Spec    *spec.Spec
	Log     *slog.Logger
	TLSFP   string
	LANAddr func() []string
}

type Result

type Result map[string]any

Result is a response without its id: ok plus result or error fields.

Jump to

Keyboard shortcuts

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