computer

package
v0.1.54 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 30 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 computer adds authenticated transports to the existing workspace API. The relay sees an SSH ciphertext stream, never daemon HTTP or terminal content.

Index

Constants

View Source
const APIPort = 8790
View Source
const PairingPort = 8793
View Source
const PairingVersion = 3
View Source
const Version = 1

Variables

This section is empty.

Functions

func ControlPatterns

func ControlPatterns() []string

ControlPatterns is generated from the actual registration for OpenAPI parity.

func Lock

func Lock(directory string) (func(), error)

Lock prevents competing launches from replacing the computer's host identity or reconciling the same workspace state. OS locks release automatically on exit.

Types

type ConnectionMetadata

type ConnectionMetadata struct {
	Provider string `json:"provider"`
	Address  string `json:"address"`
}

ConnectionMetadata is descriptive only. Provider credentials never cross the daemon API; phones still authenticate and pin the SSH identity for every route.

type Device

type Device struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	PublicKey    string    `json:"publicKey"`
	CreatedAt    time.Time `json:"createdAt"`
	Revoked      bool      `json:"revoked"`
	DirectoryURL string    `json:"directoryURL,omitempty"`
}

type Forward

type Forward struct {
	ForwardRequest
	ExpiresAt time.Time `json:"expiresAt"`
}

type ForwardRequest

type ForwardRequest struct {
	ID               string `json:"id"`
	DeviceID         string `json:"deviceId"`
	Port             int    `json:"port"`
	DesktopSessionID string `json:"desktopSessionId,omitempty"`
}

Port forwards are explicit, short-lived grants to an approved device. They never bind a public listener or grant access to other machines on the network.

type Invitation

type Invitation struct {
	Version     int       `json:"version"`
	ComputerID  string    `json:"computerId"`
	Name        string    `json:"name"`
	Fingerprint string    `json:"fingerprint"`
	Routes      []Route   `json:"routes"`
	PairingID   string    `json:"pairingId"`
	Secret      string    `json:"secret"`
	ExpiresAt   time.Time `json:"expiresAt"`
}

type Offer

type Offer struct {
	ID        string       `json:"id"`
	ExpiresAt time.Time    `json:"expiresAt"`
	Request   *PairRequest `json:"request,omitempty"`
	Status    string       `json:"status"`
	Completed bool         `json:"completed,omitempty"`
	// contains filtered or unexported fields
}

type PairRequest

type PairRequest struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	PublicKey string `json:"publicKey"`
	Signature string `json:"signature,omitempty"`
}

type PeerBridge

type PeerBridge interface {
	PeerAuthorize(user string, key ssh.PublicKey) (string, bool)
	ServePeerChannel(id string, incoming ssh.NewChannel)
}

PeerBridge grants a daemon a bot-only channel. It never grants the phone's workspace API, pairing credentials, shell or port-forwarding capabilities. The bot service owns key enrollment, scope checks and revocation.

type PeerDirectoryReader

type PeerDirectoryReader struct {
	ID        string
	PublicKey string
}

type PeerDirectorySource

type PeerDirectorySource interface {
	PeerDirectoryReaders() []PeerDirectoryReader
}

PeerDirectorySource supplies separately enrolled bot peers with read access to encrypted address records. These readers are never computer Devices and gain no workspace API, shell, pairing or port-forwarding authorization. Callers must not hold the peer registry lock while calling back into Server.

type PeerDiscoveryGrant

type PeerDiscoveryGrant struct {
	Version            int    `json:"version"`
	URL                string `json:"url"`
	DirectoryID        string `json:"directoryId"`
	ComputerID         string `json:"computerId"`
	RegistryID         string `json:"registryId"`
	DeviceID           string `json:"deviceId"`
	Sequence           uint64 `json:"sequence"`
	Secret             string `json:"secret"`
	HostKeyFingerprint string `json:"hostKeyFingerprint"`
}

PeerDiscoveryGrant is private recovery material for an enrolled daemon. It travels only inside the authenticated peer channel, never public descriptors, owner-facing discovery responses, prompts or model-visible tool results.

type Route

type Route struct {
	Kind string `json:"kind"`
	Host string `json:"host,omitempty"`
	Port int    `json:"port,omitempty"`
	URL  string `json:"url,omitempty"`
}

type Server

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

func New

func New(directory, apiAddress, apiToken, registryID string) (*Server, error)

func (*Server) BotPeerDiscoveryChanged

func (s *Server) BotPeerDiscoveryChanged()

BotPeerDiscoveryChanged refreshes only encrypted directory reader grants. The bridge calls this after committing enrollment/revocation and releasing its own lock so publisher snapshots cannot invert the two lock orders.

func (*Server) BotPeerIdentity

func (s *Server) BotPeerIdentity() (fingerprint string, routes []Route)

BotPeerIdentity returns the existing pinned computer identity and a detached route snapshot. Reading it neither changes saved phone approvals nor opens a listener. Route changes remain owned by the normal computer connection flow.

func (*Server) BotPeerRecovery

func (s *Server) BotPeerRecovery(publicKey string) (*PeerDiscoveryGrant, error)

func (*Server) Close

func (s *Server) Close()

func (*Server) Decide

func (s *Server) Decide(id, requestID string, approve bool, replaceDeviceIDs ...string) (Device, error)

func (*Server) Fingerprint

func (s *Server) Fingerprint() string

func (*Server) ForceUpdatePending

func (s *Server) ForceUpdatePending() bool

Only this accepted, still-active request may bypass idle admission. The normal exclusive lease still prevents two controllers/installers replacing a service.

func (*Server) Handle

func (s *Server) Handle(raw net.Conn)

func (*Server) Info

func (s *Server) Info() map[string]any

func (*Server) Invite

func (s *Server) Invite(routes []Route) (Invitation, error)

func (*Server) PairHandler

func (s *Server) PairHandler(offerID string) http.Handler

func (*Server) PendingActivity

func (s *Server) PendingActivity() int

Active invitations reserve the service until expiry, including a lost approval acknowledgement. An idle update must not invalidate a QR halfway through pairing.

func (*Server) Register

func (s *Server) Register(mux *http.ServeMux, guards ...func(http.HandlerFunc) http.HandlerFunc)

func (*Server) Request

func (s *Server) Request(offerID string, req PairRequest) (*Offer, error)

func (*Server) Revoke

func (s *Server) Revoke(id string) error

func (*Server) SetBotPeerBridge

func (s *Server) SetBotPeerBridge(bridge PeerBridge)

func (*Server) SetDesktopViewer

func (s *Server) SetDesktopViewer(port int, authorize func(string) error, viewer func(context.Context, string, io.ReadWriteCloser) error)

Desktop uses a virtual direct-tcpip destination on the existing SSH server. The surface service owns authentication, session lifetime and input control.

func (*Server) Start

func (s *Server) Start(sshAddress, websocketAddress, directory string) error

Start exposes only the SSH protocol. The daemon HTTP API stays on loopback. WebSocket is an alternative byte carrier for the same pinned SSH handshake.

func (*Server) WebSocket

func (s *Server) WebSocket(w http.ResponseWriter, r *http.Request)

type Update

type Update struct {
	ID        string    `json:"id"`
	Version   string    `json:"version"`
	Status    string    `json:"status"`
	Force     bool      `json:"force,omitempty"`
	Error     string    `json:"error,omitempty"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Jump to

Keyboard shortcuts

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