Documentation
¶
Index ¶
- func Dir() (string, error)
- func DirFrom(baseDir string) string
- func EnsureDir() error
- func Path() (string, error)
- type Config
- func (c *Config) AddTrustedFolder(dir string) bool
- func (c *Config) CurrentMode() string
- func (c *Config) RememberSitePort(root string, port int)
- func (c *Config) RemoveTrustedFolder(dir string) bool
- func (c *Config) ResolvePort() (net.Listener, error)
- func (c *Config) Save() error
- func (c *Config) SetMode(mode string) (prev string)
- func (c *Config) SetStartOnLogin(v bool)
- func (c *Config) SitePort(root string) int
- func (c *Config) StartOnLoginEnabled() bool
- func (c *Config) TrustedFolderList() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Mode string `json:"mode"`
StartOnLogin bool `json:"startOnLogin"`
Port int `json:"port"`
// SitePorts remembers the loopback port each opened tree was served on.
// Browser storage (localStorage, IndexedDB, cookies) is scoped to an origin,
// and the port is part of the origin, so handing a tree a fresh random port
// on every launch silently orphans whatever the page stored last time.
// Keyed by the tree's root directory.
SitePorts map[string]int `json:"sitePorts,omitempty"`
// TrustedFolders are folders the user marked as their own. A file opened from
// inside one is silently allowed to read that folder's whole tree with no
// permission prompt. Stored as canonical absolute paths; the caller canonicalizes
// and validates (inside home, not the config tree, no hidden component) before
// adding, so containment checks here can stay simple.
TrustedFolders []string `json:"trustedFolders,omitempty"`
// contains filtered or unexported fields
}
func (*Config) AddTrustedFolder ¶ added in v1.2.0
AddTrustedFolder records dir as trusted, returning false if it was already present. dir must already be canonical (resolved, home-contained).
func (*Config) CurrentMode ¶ added in v1.2.0
CurrentMode returns the launch mode under the lock.
func (*Config) RememberSitePort ¶ added in v1.2.0
RememberSitePort records the port a tree was served on so the next launch can reuse it and keep the origin stable.
func (*Config) RemoveTrustedFolder ¶ added in v1.2.0
RemoveTrustedFolder drops dir from the trusted list, returning whether it was present.
func (*Config) SetMode ¶ added in v1.2.0
SetMode sets the launch mode and returns the previous value so a caller can roll back if a following Save fails.
func (*Config) SetStartOnLogin ¶ added in v1.2.0
SetStartOnLogin sets the start-on-login preference under the lock.
func (*Config) SitePort ¶ added in v1.2.0
SitePort returns the port previously used for root, or 0 if there is none.
func (*Config) StartOnLoginEnabled ¶ added in v1.2.0
StartOnLoginEnabled reports the start-on-login preference under the lock.
func (*Config) TrustedFolderList ¶ added in v1.2.0
TrustedFolderList returns a copy of the trusted folders. It exists so callers can read the list without touching the field under the lock.