config

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package config handles the launcher configuration.

Index

Constants

This section is empty.

Variables

View Source
var TorProxyTypes = []string{"SOCKS 4", "SOCKS 5", "HTTP(S)"}

TorProxyTypes are the proxy protocols supported by tor.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Architecture is the current architecture derived at runtime ("linux32",
	// "linux64").
	Architecture string `json:"-"`

	// Channel is the Tor Browser channel to install ("release", "alpha")
	Channel string `json:"channel,omitempty"`

	// Locale is the Tor Browser locale to install ("en-US", "ja").
	Locale string `json:"locale,omitempty"`

	// LastUpdateCheck is the UNIX time when the last update check was
	// sucessfully completed.
	LastUpdateCheck int64 `json:"lastUpdateCheck,omitEmpty"`

	// ForceUpdate is set if the installed bundle is known to be obsolete.
	ForceUpdate bool `json:"forceUpdate"`

	// SkipPartialUpdate is set if the partial update has failed to apply.
	SkipPartialUpdate bool `json:"skipPartialUpdate"`

	// Tor is the Tor network configuration.
	Tor Tor `json:"tor,omitEmpty"`

	// Sandbox is the sandbox configuration.
	Sandbox Sandbox `json:"sandbox,omitEmpty"`

	// FirstLaunch is set for the first launch post install.
	FirstLaunch bool `json:"firstLaunch"`

	// LastVersion is the last `sandboxed-tor-browser` version that wrote
	// the config file.
	LastVersion string `json:"lastVersion"`

	// UseSystemTor indicates if a system tor daemon should be used.
	UseSystemTor bool `json:"-"`

	// SystemTorControlPort is the system tor daemon control port network.
	SystemTorControlNet string `json:"-"`

	// SystemTorControlAddr is the system tor daemon control port address.
	SystemTorControlAddr string `json:"-"`

	// RumtineDir is `$XDG_RUNTIME_DIR/appDir`.
	RuntimeDir string `json:"-"`

	// UserDataDir is `$XDG_USER_DATA_DIR/appDir`.
	UserDataDir string `json:"-"`

	// BundeInstallDir is `UserDataDir/bundleInstallDir`.
	BundleInstallDir string `json:"-"`

	// TorDataDir is `UserDataDir/torDataDir`.
	TorDataDir string `json:"-"`

	// ConfigDir is `XDG_CONFIG_HOME/appDir`.
	ConfigDir string `json:"-"`

	// ConfigVersionChanged indicates that the config file was from an old
	// version.
	ConfigVersionChanged bool `json:"-"`
	// contains filtered or unexported fields
}

Config is the sandboxed-tor-browser configuration instance.

func New

func New(version string) (*Config, error)

New creates a new config object and populates it with the configuration from disk if available, default values otherwise.

func (*Config) NeedsUpdateCheck

func (cfg *Config) NeedsUpdateCheck() bool

NeedsUpdateCheck returns true if the bundle needs to be checked for updates, and possibly updated.

func (*Config) ResetDirty

func (cfg *Config) ResetDirty()

ResetDirty resets the config's dirty flag, causing changes to be discarded on the Sync call. This routine should only be used immediately prior to termination.

func (*Config) Sanitize

func (cfg *Config) Sanitize()

Sanitize validates the config, and brings it inline with reality.

func (*Config) SetChannel

func (cfg *Config) SetChannel(c string)

SetChannel sets the configured channel, and marks the config dirty.

func (*Config) SetFirstLaunch

func (cfg *Config) SetFirstLaunch(b bool)

SetFirstLaunch sets the first launch flag and marks the config dirty.

func (*Config) SetForceUpdate

func (cfg *Config) SetForceUpdate(b bool)

SetForceUpdate sets the bundle as needed an update and marks the config dirty.

func (*Config) SetLastUpdateCheck

func (cfg *Config) SetLastUpdateCheck(t int64)

SetLastUpdateCheck sets the last update check time and marks the config dirty.

func (*Config) SetLocale

func (cfg *Config) SetLocale(l string)

SetLocale sets the configured locale, and marks the config dirty.

func (*Config) SetSkipPartialUpdate

func (cfg *Config) SetSkipPartialUpdate(b bool)

SetSkipPartailUpdate sets the bundle as needing a complete update as opposed to a partial one, and marks the config dirty.

func (*Config) Sync

func (cfg *Config) Sync() error

Sync flushes config changes to disk, if the config is dirty.

type Manifest

type Manifest struct {
	// Version is the installed version.
	Version string `json:"version,omitEmpty"`

	// Architecture is the installed Tor Browser architecture.
	Architecture string `json:"architecture,omitEmpty"`

	// Channel is the installed Tor Browser channel.
	Channel string `json:"channel,omitEmpty"`

	// Locale is the installed Tor Browser locale.
	Locale string `json:"locale,omitEmpty"`
	// contains filtered or unexported fields
}

Manifest contains the installed Tor Browser information.

func LoadManifest

func LoadManifest(cfg *Config) (*Manifest, error)

LoadManifest loads a manifest if present. Note that a missing manifest is not treated as an error.

func NewManifest

func NewManifest(cfg *Config, version string) *Manifest

NewManifest returns a new manifest.

func (*Manifest) BundleUpdateVersionValid

func (m *Manifest) BundleUpdateVersionValid(vStr string) bool

BundleUpdateVersionValid returns true if the proposed update version is actually an update.

func (*Manifest) BundleVersionAtLeast

func (m *Manifest) BundleVersionAtLeast(vStr string) bool

BundleVersionAtLeast returns true if the bundle version is greater than or equal to the specified version.

func (*Manifest) Purge

func (m *Manifest) Purge()

Purge deletes the manifest.

func (*Manifest) SetVersion

func (m *Manifest) SetVersion(v string)

SetVersion sets the manifest version and marks the config dirty.

func (*Manifest) Sync

func (m *Manifest) Sync() error

Sync flushes the manifest to disk, if the manifest is dirty.

type Sandbox

type Sandbox struct {

	// Display is the X11 DISPLAY to use in the sandbox.  If omitted, the
	// host system DISPLAY from the env var will be used.
	Display string `json:"display,omitEmpty"`

	// EnablePulseAudio enables access to the host PulseAudio daemon inside the
	// sandbox.
	EnablePulseAudio bool `json:"enablePulseAudio"`

	// EnableAVCodec enables extra codecs via ffmpeg's libavcodec.so inside
	// the sandbox.
	EnableAVCodec bool `json:"enableAVCodec"`

	// EnableCircuitDisplay enables the Tor Browser circuit display.
	EnableCircuitDisplay bool `json:"enableCircuitDisplay"`

	// EnableAmnesiacProfileDirectory enables amnesiac profile directories.
	EnableAmnesiacProfileDirectory bool `json:"enableAmnesiacProfileDirectory"`

	// DesktopDir is the directory to be bind mounted instead of the default
	// bundle Desktop directory.
	DesktopDir string `json:"desktopDir,omitEmpty"`

	// DownloadsDir is the directory to be bind mounted instead of the default
	// bundle Downloads directory.
	DownloadsDir string `json:"downloadsDir,omitEmpty"`
	// contains filtered or unexported fields
}

Sandbox contains the sandbox specific config options.

func (*Sandbox) SetDesktopDir

func (sb *Sandbox) SetDesktopDir(s string)

SetDesktopDir sets the sandbox `~/Desktop` bind mount source and marks the config dirty.

func (*Sandbox) SetDisplay

func (sb *Sandbox) SetDisplay(s string)

SetDisplay sets the sandbox `DISPLAY` override and marks the config dirty.

func (*Sandbox) SetDownloadsDir

func (sb *Sandbox) SetDownloadsDir(s string)

SetDownloadsDir sets the sandbox `~/Downloads` bind mount source and marks the config dirty.

func (*Sandbox) SetEnableAVCodec

func (sb *Sandbox) SetEnableAVCodec(b bool)

SetEnableAVCodec sets the sandbox libavcodec enable and marks the config dirty.

func (*Sandbox) SetEnableAmnesiacProfileDirectory

func (sb *Sandbox) SetEnableAmnesiacProfileDirectory(b bool)

SetEnableAmnesiacProfileDirectory sets the amnesiac profile directory enable and marks the config dirty.

func (*Sandbox) SetEnableCircuitDisplay

func (sb *Sandbox) SetEnableCircuitDisplay(b bool)

SetEnableCircuitDisplay sets the circit display enable and marks the config dirty.

func (*Sandbox) SetEnablePulseAudio

func (sb *Sandbox) SetEnablePulseAudio(b bool)

SetEnablePulseAudio sets the sandbox pulse audo enable and marks the config dirty.

type Tor

type Tor struct {

	// CtrlPassword is the unhashed onctol port password.
	CtrlPassword string `json:"-"`

	// UseProxy is if the Tor network should be reached via a local proxy.
	UseProxy bool `json:"useProxy"`

	// ProxyType is the proxy protocol that should be used.
	ProxyType string `json:"proxyType"`

	// ProxyAddress is the proxy address that should be used.
	ProxyAddress string `json:"proxyAddress"`

	// ProxyPort is the proxy port that should be used.
	ProxyPort string `json:"proxyPort"`

	// ProxyUsername is the optional proxy username.
	ProxyUsername string `json:"proxyUsername"`

	// ProxyPassword is the optional proxy password.
	ProxyPassword string `json:"proxyPassword"`

	// UseBridges is if the Tor network should be reached via a bridge.
	UseBridges bool `json:"useBridges"`

	// InternalBridgeType is the bridge transport to use when using built in
	// bridges.
	InternalBridgeType string `json:"internalBridgeType"`

	// InternalBridgeSeed is the seed to use when permuting the internal
	// bridges for load balancing purposes.
	InternalBridgeSeed int64 `json:"internalBridgeSeed"`

	// UseCustomBridges is if the user provided bridges should be used.
	UseCustomBridges bool `json:"useCustomBridges"`

	// CustomBridges is the user provided bridge lines.
	CustomBridges string `json:"customBridges"`
	// contains filtered or unexported fields
}

Tor contains the Tor network config options.

func (*Tor) SetCustomBridges

func (t *Tor) SetCustomBridges(s string)

SetCustomBridges sets the user provided custom bridge lines, and maarks the config dirty.

func (*Tor) SetInternalBridgeSeed

func (t *Tor) SetInternalBridgeSeed(i int64)

SetInternalBridgeSeed sets the seed to use when permuting the internal bridges for load balancing purposes and marks the config dirty.

func (*Tor) SetInternalBridgeType

func (t *Tor) SetInternalBridgeType(s string)

SetInternalBridgeType sets the transport to be used when using built in bridges and marks the config dirty.

func (*Tor) SetProxyAddress

func (t *Tor) SetProxyAddress(s string)

SetProxyAddress sets the proxy address to be used by tor and marks the config dirty.

func (*Tor) SetProxyPassword

func (t *Tor) SetProxyPassword(s string)

SetProxyPassword sets the proxy password to be used by tor and marks the config dirty.

func (*Tor) SetProxyPort

func (t *Tor) SetProxyPort(s string)

SetProxyPort sets the proxy port to be used by tor and marks the config dirty.

func (*Tor) SetProxyType

func (t *Tor) SetProxyType(s string)

SetProxyType sets the proxy protocol to be used by tor and marks the config dirty.

func (*Tor) SetProxyUsername

func (t *Tor) SetProxyUsername(s string)

SetProxyUsername sets the proxy username to be used by tor and marks the config dirty.

func (*Tor) SetUseBridges

func (t *Tor) SetUseBridges(b bool)

SetUseBridges sets if the Tor network should be reached via a Bridge and marks the config dirty.

func (*Tor) SetUseCustomBridges

func (t *Tor) SetUseCustomBridges(b bool)

SetUseCustomBridges sets if the user provided custom bridges should be used and marks the config dirty.

func (*Tor) SetUseProxy

func (t *Tor) SetUseProxy(b bool)

SetUseProxy sets if the Tor network should be reached via a local proxy and marks the config dirty.

Jump to

Keyboard shortcuts

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