remotedesktops

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 26 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 remotedesktops manages Bektinet hosts: their saved Mac passwords, encrypted like Wi-Fi passwords, sessions that exchange a password for a single-use stream ticket, and the WebSocket relay that carries a browser's stream without decoding it.

Index

Constants

View Source
const (
	DefaultPort = 3390
	// Matches the host's ticket lifetime.
	SessionLifetime = 30 * time.Second
)

Variables

View Source
var (
	ErrNotFound          = errors.New("remote desktop not found")
	ErrConflict          = errors.New("remote desktop conflict")
	ErrKeyMissing        = errors.New("remote desktop password encryption is not configured")
	ErrTransactorMissing = errors.New("remote desktop transactor not configured")
	ErrRelayToken        = errors.New("invalid relay token")
)

Functions

func NormalizeFingerprint

func NormalizeFingerprint(value string) (string, error)

NormalizeFingerprint accepts 32 hex bytes with or without separators and returns the lowercase colon-separated form that Bektinet shows.

Types

type ErrUnavailable

type ErrUnavailable struct{ Message string }

ErrUnavailable wraps every reason a host could not be used: unreachable, wrong certificate, or a refused sign-in. Its message is safe to show to administrators.

func (ErrUnavailable) Error

func (e ErrUnavailable) Error() string

type PGXTransactor

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

func NewPGXTransactor

func NewPGXTransactor(pool *pgxpool.Pool) *PGXTransactor

func (*PGXTransactor) InTx

func (t *PGXTransactor) InTx(ctx context.Context, fn func(q Querier) error) error

type Querier

type Querier interface {
	ListRemoteDesktops(ctx context.Context) ([]db.RemoteDesktop, error)
	GetRemoteDesktopByID(ctx context.Context, arg db.GetRemoteDesktopByIDParams) (db.RemoteDesktop, error)
	CreateRemoteDesktop(ctx context.Context, arg db.CreateRemoteDesktopParams) (db.RemoteDesktop, error)
	UpdateRemoteDesktop(ctx context.Context, arg db.UpdateRemoteDesktopParams) (db.RemoteDesktop, error)
	DeleteRemoteDesktop(ctx context.Context, arg db.DeleteRemoteDesktopParams) error
	PinRemoteDesktopCertificate(ctx context.Context, arg db.PinRemoteDesktopCertificateParams) (db.RemoteDesktop, error)
	CreateAuditLog(ctx context.Context, arg db.CreateAuditLogParams) (db.AuditLog, error)
}

type Service

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

func NewService

func NewService(queries Querier, tx Transactor, passwordKey []byte, relaySecret []byte, issuer string) (*Service, error)

NewService takes the password key (nil or empty when not configured) and the secret that signs relay tokens.

func (*Service) Create

func (s *Service) Create(ctx context.Context, actor db.User, input api.RemoteDesktopWrite) (db.RemoteDesktop, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, actor db.User, id uuid.UUID) error

func (*Service) DialRelay

func (s *Service) DialRelay(ctx context.Context, id uuid.UUID, token string) (*websocket.Conn, error)

DialRelay checks a relay token for this host and connects to the host, ready for Relay.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]db.RemoteDesktop, error)

func (*Service) Relay

func (s *Service) Relay(ctx context.Context, browser, host *websocket.Conn) string

Relay carries messages between the browser and the host until either side closes, and says which side ended it and why.

func (*Service) StartSession

func (s *Service) StartSession(ctx context.Context, actor db.User, id uuid.UUID, offer string) (Session, error)

StartSession signs in to the host with its saved password and returns a stream ticket. With the browser's WebRTC offer, it also returns the host's answer for the direct path; without one, or when the host cannot answer, the browser uses the relay.

func (*Service) Update

func (s *Service) Update(ctx context.Context, actor db.User, id uuid.UUID, patch api.RemoteDesktopPatch) (db.RemoteDesktop, error)

type Session

type Session struct {
	Ticket     string
	RelayToken string
	ExpiresIn  time.Duration
	// The host's WebRTC answer to the browser's offer; empty when there was none.
	Answer string
}

Session is what a browser needs to open a stream: the host's ticket, and a relay token that lets it open the relay for this host for a short time.

type Transactor

type Transactor interface {
	InTx(ctx context.Context, fn func(q Querier) error) error
}

type ValidationError

type ValidationError struct{ Message string }

func (ValidationError) Error

func (e ValidationError) Error() string

Jump to

Keyboard shortcuts

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