cfg

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 4 more Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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
)
View Source
var Version = "development"

Version is the current version of the binary. Set at compile time using ldflags (see .github/workflows/build.yml).

Functions

func SelfUpdate

func SelfUpdate(ctx context.Context)

SelfUpdate checks for updates and prompts the user to update if there is one.

Types

type Config

type Config struct {
	sync.RWMutex

	Filter struct {
		FilterLists []FilterList `json:"filterLists"`
	} `json:"filter"`
	Certmanager struct {
		CAInstalled bool `json:"caInstalled"`
	} `json:"certmanager"`
	Proxy struct {
		Port         int      `json:"port"`
		IgnoredHosts []string `json:"ignoredHosts"`
	} `json:"proxy"`
	// 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 NewConfig

func NewConfig() (*Config, error)

func (*Config) AddFilterList

func (c *Config) AddFilterList(list FilterList) string

AddFilterList adds a new filter list to the list of enabled filter lists.

func (*Config) GetCAInstalled

func (c *Config) GetCAInstalled() bool

GetCAInstalled returns whether the CA is installed.

func (*Config) GetFilterLists

func (c *Config) GetFilterLists() []FilterList

GetFilterLists returns the list of enabled filter lists.

func (*Config) GetIgnoredHosts added in v0.4.0

func (c *Config) GetIgnoredHosts() []string

GetIgnoredHosts returns the list of ignored hosts.

func (*Config) GetPort

func (c *Config) GetPort() int

GetPort returns the port the proxy is set to listen on.

func (*Config) GetVersion

func (c *Config) GetVersion() string

func (*Config) RemoveFilterList

func (c *Config) RemoveFilterList(url string) string

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

func (c *Config) Save() error

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

func (c *Config) SetCAInstalled(caInstalled bool)

SetCAInstalled sets whether the CA is installed.

func (*Config) SetIgnoredHosts added in v0.4.0

func (c *Config) SetIgnoredHosts(hosts []string) error

SetIgnoredHosts sets the list of ignored hosts.

func (*Config) SetPort

func (c *Config) SetPort(port int) string

SetPort sets the port the proxy is set to listen on.

func (*Config) ToggleFilterList

func (c *Config) ToggleFilterList(url string, enabled bool) string

ToggleFilterList toggles the enabled state of a filter list.

type FilterList

type FilterList struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	URL     string `json:"url"`
	Enabled bool   `json:"enabled"`
}

Jump to

Keyboard shortcuts

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