relayconfig

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 24 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 relayconfig owns saved profiles, active relay selection and frontend choice.

Index

Constants

View Source
const (
	PathEnvironment = "WINDSHARE_CONFIG"

	MaximumProfiles = 64
)
View Source
const (
	Automatic = "automatic"
	Selected  = "selected"
)
View Source
const (
	MaxTURNServices = 8
	DefaultTURNTTL  = 1800
	MinimumTURNTTL  = 60
	MaximumTURNTTL  = 86400
	TURNStatic      = "shared_static"
	TURNCoturn      = "coturn"
	TURNCloudflare  = "cloudflare"
	RoleParallel    = "parallel"
	RoleFallback    = "fallback"
)

Variables

View Source
var (
	ErrConfig   = errors.New("invalid sharing configuration")
	ErrRelayURL = errors.New("invalid relay URL")
	// Decode wraps both ErrConfig and ErrRepeatedMember for ambiguous names.
	ErrRepeatedMember = configjson.ErrRepeatedMember
)
View Source
var ErrFrontURL = errors.New("invalid frontend URL")

Functions

func Encode

func Encode(config Config) ([]byte, error)

Encode serializes only portable user settings.

func Path

func Path() (string, error)

func RelayRouteGuidance

func RelayRouteGuidance(hint networkendpoint.RelayBaseHint) string

RelayRouteGuidance applies to an observed HTTP failure. The same spelling can still name a working mount or an unused profile.

func Save

func Save(config Config) error

Save replaces the entire allowed set. Merging would silently retain providers that a newly imported private-only configuration deliberately excludes.

func SelectRelays

func SelectRelays(config Config, override []string) ([]relayprofile.Candidate, error)

SelectRelays treats a saved list or explicit override as the complete allowed set. No infrastructure is added implicitly, including development listeners.

func ShareIntent

func ShareIntent(config Config, override []string) (relayprofile.Intent, error)

func ValidateFrontURL

func ValidateFrontURL(raw string) error

Reject literal whitespace rather than rewriting the saved address: capability construction trims some copied characters and encodes others into the path. Explicitly escaped path characters remain part of the configured address.

func ValidateTURNServices added in v0.1.6

func ValidateTURNServices(services []TURNService) error

Types

type Config

type Config struct {
	TURNServices   []TURNService
	FrontURL       string
	Profiles       []relayprofile.Candidate
	ActiveRelays   []string
	ConfiguredOnly bool
}

func Decode

func Decode(reader io.Reader) (Config, error)

func Load

func Load() (Config, error)

func ReadSettings

func ReadSettings(tx *statefile.Transaction) (Config, error)

ReadSettings lets the setup store observe settings under the shared commit lock.

func (Config) CredentialProfile

func (c Config) CredentialProfile(address, key string) relayprofile.Candidate

CredentialProfile updates only the secret for an existing endpoint. A manual credential carries no discovery metadata and cannot withdraw a published capability.

func (Config) MergeRelay

func (c Config) MergeRelay(p relayprofile.Candidate) (Config, error)

MergeRelay runs on a copy for both enrollment preflight and its eventual commit. Re-discovery cannot erase a device key or re-enable a deliberately disabled profile.

func (Config) Preferences

func (c Config) Preferences(defaultFrontend string) Preferences

func (*Config) RemoveRelay added in v0.1.5

func (c *Config) RemoveRelay(address string) error

func (*Config) SetEnabled

func (c *Config) SetEnabled(address string, enabled bool) error

func (*Config) SetMode

func (c *Config) SetMode(mode string) error

func (Config) SettingsRevision

func (config Config) SettingsRevision() string

func (Config) Validate

func (config Config) Validate() error

type FileStore

type FileStore struct{ Path string }

FileStore is injectable so applications never read another caller's configuration implicitly.

func (FileStore) Load

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

func (FileStore) Location

func (store FileStore) Location() (string, error)

Location identifies the namespace shared by settings and durable setup commits.

func (FileStore) Save

func (store FileStore) Save(config Config) error

func (FileStore) Update

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

Update serializes user edits across processes. Network activity never runs in its callback; setup commits use the same storage transaction boundary.

type PreferenceEdit

type PreferenceEdit struct {
	Action string `json:"action"`
	Value  string `json:"value"`
}

func (PreferenceEdit) Apply

func (e PreferenceEdit) Apply(c *Config) error

type Preferences

type Preferences struct {
	Mode           string      `json:"mode"`
	Frontend       string      `json:"frontend"`
	CustomFrontend bool        `json:"custom_frontend"`
	Relays         []RelayView `json:"relays"`
	AtCapacity     bool        `json:"at_capacity"`
}

type RelayView

type RelayView struct {
	URL             string `json:"url"`
	Enabled         bool   `json:"enabled"`
	ConsoleURL      string `json:"console_url,omitempty"`
	OfferedFrontend string `json:"offered_frontend,omitempty"`
}

type TURNService added in v0.1.6

type TURNService struct {
	ID           string   `json:"id"`
	Kind         string   `json:"kind"`
	Role         string   `json:"role,omitempty"`
	URLs         []string `json:"urls,omitempty"`
	Username     string   `json:"username,omitempty"`
	Password     string   `json:"password,omitempty"`
	SharedSecret string   `json:"shared_secret,omitempty"`
	KeyID        string   `json:"key_id,omitempty"`
	APIToken     string   `json:"api_token,omitempty"`
	TTLSeconds   int      `json:"ttl_seconds,omitempty"`
}

func CloneTURNServices added in v0.1.6

func CloneTURNServices(services []TURNService) []TURNService

func (TURNService) EffectiveRole added in v0.1.6

func (service TURNService) EffectiveRole() string

func (TURNService) TTL added in v0.1.6

func (service TURNService) TTL() int

Jump to

Keyboard shortcuts

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