Documentation
¶
Overview ¶
Package config provides a handler for fetching and storing proxy configurations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFetchingConfig is returned by [ConfigHandler.GetConfig] when if there was an error // fetching the configuration. ErrFetchingConfig = errors.New("failed to fetch config") )
var ErrNoWGKey = errors.New("no wg key")
Functions ¶
Types ¶
type Config ¶
type Config struct {
ConfigResponse C.ConfigResponse
PreferredLocation C.ServerLocation
}
Config includes all configuration data from the Lantern API as well as any stored local preferences.
type ConfigHandler ¶
type ConfigHandler struct {
// contains filtered or unexported fields
}
ConfigHandler handles fetching the proxy configuration from the proxy server. It provides access to the most recent configuration.
func NewConfigHandler ¶
func NewConfigHandler(options Options) *ConfigHandler
NewConfigHandler creates a new ConfigHandler that fetches the proxy configuration every pollInterval.
func (*ConfigHandler) GetConfig ¶
func (ch *ConfigHandler) GetConfig() (*Config, error)
GetConfig returns the current configuration. It returns an error if the config is not yet available.
func (*ConfigHandler) SetPreferredServerLocation ¶
func (ch *ConfigHandler) SetPreferredServerLocation(country, city string)
SetPreferredServerLocation sets the preferred server location to connect to
func (*ConfigHandler) Stop ¶
func (ch *ConfigHandler) Stop()
Stop stops the ConfigHandler from fetching new configurations.
type ListenerFunc ¶
ListenerFunc is a function that is called when the configuration changes.
type NewConfigEvent ¶
NewConfigEvent is emitted when the configuration changes.