Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package config provides a handler for fetching and storing proxy configurations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFetchingConfig is returned by [ConfigHandler.GetConfig] when if there was an error
	// fetching the configuration.
	ErrFetchingConfig = errors.New("failed to fetch config")
)
View Source
var ErrNoWGKey = errors.New("no wg key")

Functions

func DNSTTConfigUpdate

func DNSTTConfigUpdate(ctx context.Context, configURL string, httpClient *http.Client, pollInterval time.Duration)

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 Fetcher

type Fetcher interface {
	// contains filtered or unexported methods
}

type ListenerFunc

type ListenerFunc func(oldConfig, newConfig *Config) error

ListenerFunc is a function that is called when the configuration changes.

type NewConfigEvent

type NewConfigEvent struct {
	events.Event
	Old *Config
	New *Config
}

NewConfigEvent is emitted when the configuration changes.

type NewDNSTTConfigEvent

type NewDNSTTConfigEvent struct {
	events.Event
	New dnstt.DNSTT
}

type Options

type Options struct {
	PollInterval time.Duration
	HTTPClient   *http.Client
	SvrManager   ServerManager
	User         common.UserInfo
	DataDir      string
	Locale       string
	APIHandler   *api.APIClient
}

type ServerManager

type ServerManager interface {
	SetServers(serverGroup string, opts servers.Options) error
}

Jump to

Keyboard shortcuts

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