relaysetup

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 25 Imported by: 1 module, 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 relaysetup implements discover, approve and install for native applications.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDenied          = errors.New("relay access was refused; approve this device or install a new access key")
	ErrExpired         = errors.New("relay enrollment expired; start setup again")
	ErrPendingSetup    = errors.New("another relay setup is pending; finish or cancel it first")
	ErrNoPendingSetup  = errors.New("no relay setup is pending; nothing was cancelled")
	ErrSetupRunning    = errors.New("relay setup is already running; finish or cancel it first")
	ErrSettingsChanged = errors.New("sharing settings changed during relay setup")
	ErrSetupSuperseded = errors.New("relay setup was completed, cancelled or replaced")
)
View Source
var ErrInvalidDeviceName = fmt.Errorf("device name must be valid UTF-8, 1 to %d bytes, not blank, and free of control characters", maximumDeviceNameBytes)

ErrInvalidDeviceName identifies input that cannot be preserved by enrollment and checkpoint serialization.

View Source
var ErrLocalCredentialRequired = errors.New("this node requires an access key from its owner")

Functions

func DefaultDeviceName

func DefaultDeviceName(suggestion string) string

DefaultDeviceName makes an environment-provided display label usable without user intervention. Explicit names must be validated without rewriting them.

func ValidateDeviceName

func ValidateDeviceName(name string) error

ValidateDeviceName shares the enrollment rule with callers that can reject input before starting setup or contacting a relay.

Types

type Dependencies

type Dependencies struct {
	Store       Store
	Cache       DiscoveryCache
	HTTP        HTTPClient
	OpenBrowser func(context.Context, string) error
	Now         func() time.Time
	Random      io.Reader
	Wait        func(context.Context, time.Duration) error
	Log         *slog.Logger
}

type DiscoveryCache

type DiscoveryCache interface {
	Save(context.Context, relayprofile.Candidate, turn.Capability, time.Time) error
}

type FileStore

type FileStore struct{ Settings relayconfig.FileStore }

func (FileStore) Load

func (store FileStore) Load() (Snapshot, error)

func (FileStore) Update

func (store FileStore) Update(ctx context.Context, change func(*Snapshot) error) (Snapshot, error)

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type Operation

type Operation string
const (
	AddProfile        Operation = "add"
	PrivateOnboarding Operation = "private-onboarding"
)

type PendingSetup

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

func (*PendingSetup) MarshalJSON

func (pending *PendingSetup) MarshalJSON() ([]byte, error)

func (*PendingSetup) UnmarshalJSON

func (pending *PendingSetup) UnmarshalJSON(data []byte) error

type Progress

type Progress struct {
	Stage, OperationID, EnrollmentID, VerificationURL, UserCode string
	RetryAfter                                                  time.Duration
}

func (Progress) EngineEvent

func (Progress) EngineEvent()

type Recovery

type Recovery struct {
	Action                RecoveryAction
	RelayURL, OperationID string
}

type RecoveryAction

type RecoveryAction string

RecoveryAction describes what the last observed transaction permits, rather than equating every persisted checkpoint with a resumable installation.

const (
	RecoveryUnknown     RecoveryAction = "unknown"
	RecoveryRestart     RecoveryAction = "restart"
	RecoveryContinue    RecoveryAction = "continue"
	RecoveryCancel      RecoveryAction = "cancel"
	RecoveryRetryCancel RecoveryAction = "retry_cancel"
	RecoveryBlocked     RecoveryAction = "blocked"
)

type Request

type Request struct {
	URL, DeviceName string
	AccessKey       string
	Operation       Operation
	NoBrowser       bool
}

type Result

type Result struct {
	RelayURL, CredentialID, FrontURL string
	ActiveRelays                     []string
	Enabled, ConfiguredOnly          bool
	ConsoleURL, OfferedFrontend      string
}

type Service

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

func New

func New(dependencies Dependencies) *Service

func (*Service) Cancel

func (service *Service) Cancel(ctx context.Context, address string) error

func (*Service) Run

func (service *Service) Run(ctx context.Context, request Request, progress func(Progress)) (result Result, resultErr error)

type SetupError

type SetupError struct {
	Recovery Recovery
	// contains filtered or unexported fields
}

SetupError carries the workflow's last transaction outcome to its caller. Reading storage again to explain an interruption could block shutdown and describe a different operation started after this one finished.

func (*SetupError) Error

func (failure *SetupError) Error() string

func (*SetupError) Unwrap

func (failure *SetupError) Unwrap() error

type Snapshot

type Snapshot struct {
	relayconfig.Config
	Pending *PendingSetup
}

Snapshot is a setup transaction's view, never a configuration document.

type Store

type Store interface {
	Load() (Snapshot, error)
	Update(context.Context, func(*Snapshot) error) (Snapshot, error)
}

Jump to

Keyboard shortcuts

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