Documentation
¶
Overview ¶
Package relayconfig owns saved profiles, active relay selection and frontend choice.
Index ¶
- Constants
- Variables
- func Encode(config Config) ([]byte, error)
- func Path() (string, error)
- func RelayRouteGuidance(hint networkendpoint.RelayBaseHint) string
- func Save(config Config) error
- func SelectRelays(config Config, override []string) ([]relayprofile.Candidate, error)
- func ShareIntent(config Config, override []string) (relayprofile.Intent, error)
- func ValidateBootstrapNodes(nodes []string) error
- func ValidateFrontURL(raw string) error
- func ValidateTURNServices(services []TURNService) error
- type Config
- func (c Config) CommunityEnabled() bool
- func (c Config) CredentialProfile(address, key string) relayprofile.Candidate
- func (c Config) OwnedNative() []relayprofile.Candidate
- func (c Config) Preferences(defaultFrontend string) Preferences
- func (c Config) RefreshMetadata(p relayprofile.Candidate) (Config, error)
- func (c *Config) RemoveRelay(address string) error
- func (c Config) ReplaceIdentity(p relayprofile.Candidate) (Config, error)
- func (c *Config) SetEnabled(address string, enabled bool) error
- func (c *Config) SetMode(mode string) error
- func (config Config) SettingsRevision() string
- func (config Config) Validate() error
- type Eligibility
- type FileStore
- func (store FileStore) Load() (Config, error)
- func (store FileStore) Location() (string, error)
- func (s FileStore) ReadCommunityState(ctx context.Context) (Config, Eligibility, error)
- func (store FileStore) Save(config Config) error
- func (s FileStore) TakeCommunityNotice(ctx context.Context) (bool, error)
- func (store FileStore) Update(ctx context.Context, change func(*Config) error) (Config, error)
- type PreferenceEdit
- type Preferences
- type RelayView
- type TURNService
Constants ¶
const ( PathEnvironment = "WINDSHARE_CONFIG" MaximumProfiles = 64 MaximumBootstrapNodes = 16 )
const ( Automatic = "automatic" Selected = "selected" )
const ( MaxTURNServices = 8 DefaultTURNTTL = 1800 MinimumTURNTTL = 60 MaximumTURNTTL = 86400 TURNStatic = "shared_static" TURNCoturn = "coturn" TURNCloudflare = "cloudflare" RoleParallel = "parallel" RoleFallback = "fallback" )
Variables ¶
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 )
var ErrCorruptEligibility = errors.New("corrupt community eligibility state")
ErrCorruptEligibility identifies malformed or oversized derived community-eligibility.json state so callers can distinguish recoverable sidecar corruption from primary settings or filesystem I/O failures.
var ErrFrontURL = errors.New("invalid frontend URL")
Functions ¶
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 ¶
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 ValidateBootstrapNodes ¶ added in v0.1.7
ValidateBootstrapNodes enforces the shared count ceiling and strict public HTTPS origin rules for both user configuration and embedded release manifests.
func ValidateFrontURL ¶
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 {
BootstrapNodes []string
TURNServices []TURNService
FrontURL string
Profiles []relayprofile.Candidate
ActiveRelays []string
CommunityNodes *bool
ConfiguredOnly bool
}
func ReadSettings ¶
func ReadSettings(tx *statefile.Transaction) (Config, error)
ReadSettings lets the setup store observe settings under the shared commit lock.
func (Config) CommunityEnabled ¶ added in v0.1.7
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) OwnedNative ¶ added in v0.1.7
func (c Config) OwnedNative() []relayprofile.Candidate
func (Config) Preferences ¶
func (c Config) Preferences(defaultFrontend string) Preferences
func (Config) RefreshMetadata ¶ added in v0.1.7
func (c Config) RefreshMetadata(p relayprofile.Candidate) (Config, error)
RefreshMetadata preserves the device identity across capability rediscovery.
func (*Config) RemoveRelay ¶ added in v0.1.5
func (Config) ReplaceIdentity ¶ added in v0.1.7
func (c Config) ReplaceIdentity(p relayprofile.Candidate) (Config, error)
func (Config) SettingsRevision ¶
type Eligibility ¶ added in v0.1.7
type Eligibility struct {
Disabled map[string]bool `json:"disabled,omitempty"`
Paused bool `json:"paused,omitempty"`
Notified bool `json:"notified,omitempty"`
}
func EvaluateEligibility ¶ added in v0.1.7
func EvaluateEligibility(current Eligibility, c Config, observed map[string]serviceauthority.PublicRelay) Eligibility
EvaluateEligibility derives current community eligibility from previously recorded refusals, the active configuration, and any fresh owner observations. Only an explicit signed refusal is sticky across offline periods; a later reachable observation in any other state releases the refusal and its notice.
func ReadEligibility ¶ added in v0.1.7
func ReadEligibility(tx *statefile.Transaction) (Eligibility, error)
func ReconcileEligibility ¶ added in v0.1.7
func ReconcileEligibility(tx *statefile.Transaction, c Config, observed map[string]serviceauthority.PublicRelay) (Eligibility, error)
type FileStore ¶
type FileStore struct{ Path string }
FileStore is injectable so applications never read another caller's configuration implicitly.
func (FileStore) Location ¶
Location identifies the namespace shared by settings and durable setup commits.
func (FileStore) ReadCommunityState ¶ added in v0.1.7
ReadCommunityState reads saved settings and derives current community eligibility without acquiring a write lock unless commit recovery is pending. When only community-eligibility.json is corrupt, the decoded Config is still returned alongside an error matching ErrCorruptEligibility.
func (FileStore) TakeCommunityNotice ¶ added in v0.1.7
type PreferenceEdit ¶
func (PreferenceEdit) Apply ¶
func (e PreferenceEdit) Apply(c *Config) error
type Preferences ¶
type Preferences struct {
CommunityNotice uint64 `json:"community_notice,omitempty"`
CommunityNodes bool `json:"community_nodes"`
Mode string `json:"mode"`
Frontend string `json:"frontend"`
CustomFrontend bool `json:"custom_frontend"`
Relays []RelayView `json:"relays"`
AtCapacity bool `json:"at_capacity"`
}
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"`
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