Documentation
¶
Index ¶
- Variables
- func GetCacheDir() (string, error)
- type Config
- func (c *Config) AddFilterList(list filter.List) string
- func (c *Config) AddFilterLists(lists []filter.List) error
- func (c *Config) ExportDebugData() (string, error)
- func (c *Config) GetCAInstalled() bool
- func (c *Config) GetFilterLists() []filter.List
- func (c *Config) GetFilterListsByLocales(searchLocales []string) []filter.List
- func (c *Config) GetFirstLaunch() bool
- func (c *Config) GetIgnoredHosts() []string
- func (c *Config) GetLocale() string
- func (c *Config) GetPACPort() int
- func (c *Config) GetPort() int
- func (c *Config) GetRules() []string
- func (c *Config) GetTargetTypeFilterLists(targetType filter.ListType) []filter.List
- func (c *Config) GetUpdatePolicy() UpdatePolicyType
- func (c *Config) GetVersion() string
- func (c *Config) RemoveFilterList(url string) string
- func (c *Config) RunMigrations()
- func (c *Config) Save() error
- func (c *Config) SetCAInstalled(caInstalled bool)
- func (c *Config) SetIgnoredHosts(hosts []string) error
- func (c *Config) SetLocale(l string)
- func (c *Config) SetPort(port int) string
- func (c *Config) SetRules(rules []string) error
- func (c *Config) SetUpdatePolicy(p UpdatePolicyType)
- func (c *Config) ToggleFilterList(url string, enabled bool) string
- type DebugData
- type UpdatePolicyType
Constants ¶
This section is empty.
Variables ¶
var ( // ConfigDir is the path to the directory storing the application configuration. ConfigDir string // DataDir is the path to the directory storing the application data. DataDir string // Version is the current version of the application. Set at compile time for production builds using ldflags (see tasks in the /tasks/build directory). Version = "development" )
var UpdatePolicyEnum = []struct { Value UpdatePolicyType TSName string }{ {UpdatePolicyAutomatic, "AUTOMATIC"}, {UpdatePolicyPrompt, "PROMPT"}, {UpdatePolicyDisabled, "DISABLED"}, }
Functions ¶
func GetCacheDir ¶ added in v0.15.0
Types ¶
type Config ¶
type Config struct {
sync.RWMutex
Filter struct {
FilterLists []filter.List `json:"filterLists"`
// Deprecated: use Rules.
MyRules []string `json:"myRules"`
Rules []string `json:"rules"`
} `json:"filter"`
Certmanager struct {
CAInstalled bool `json:"caInstalled"`
} `json:"certmanager"`
Proxy struct {
Port int `json:"port"`
IgnoredHosts []string `json:"ignoredHosts"`
PACPort int `json:"pacPort"`
} `json:"proxy"`
UpdatePolicy UpdatePolicyType `json:"updatePolicy"`
Locale string `json:"locale"`
// contains filtered or unexported fields
}
Config stores and manages the configuration for the application. Although all fields are public, this is only for use by the JSON marshaller. All access to the Config should be done through the exported methods.
func (*Config) AddFilterList ¶
AddFilterList adds a new filter list to the list of enabled filter lists.
func (*Config) ExportDebugData ¶ added in v0.11.2
func (*Config) GetCAInstalled ¶
GetCAInstalled returns whether the CA is installed.
func (*Config) GetFilterLists ¶
GetFilterLists returns the list of enabled filter lists.
func (*Config) GetFilterListsByLocales ¶ added in v0.13.0
func (*Config) GetFirstLaunch ¶ added in v0.13.0
func (*Config) GetIgnoredHosts ¶
GetIgnoredHosts returns the list of ignored hosts.
func (*Config) GetPACPort ¶
func (*Config) GetTargetTypeFilterLists ¶
GetTargetTypeFilterLists returns the list of filter lists with particular type.
func (*Config) GetUpdatePolicy ¶
func (c *Config) GetUpdatePolicy() UpdatePolicyType
func (*Config) GetVersion ¶
func (*Config) RemoveFilterList ¶
RemoveFilterList removes a filter list from the list of enabled filter lists.
func (*Config) RunMigrations ¶
func (c *Config) RunMigrations()
RunMigrations runs the version-to-version migrations.
func (*Config) Save ¶
Save saves the config to disk. It is not thread-safe, and should only be called if the caller has a lock on the config.
func (*Config) SetCAInstalled ¶
SetCAInstalled sets whether the CA is installed.
func (*Config) SetIgnoredHosts ¶
SetIgnoredHosts sets the list of ignored hosts.
func (*Config) SetUpdatePolicy ¶
func (c *Config) SetUpdatePolicy(p UpdatePolicyType)
type UpdatePolicyType ¶
type UpdatePolicyType string
const ( UpdatePolicyAutomatic UpdatePolicyType = "automatic" UpdatePolicyPrompt UpdatePolicyType = "prompt" UpdatePolicyDisabled UpdatePolicyType = "disabled" )