config

package
v7.6.175 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 38 Imported by: 4

Documentation

Index

Constants

View Source
const (
	FeatureAuth                 = "auth"
	FeatureProxyBench           = "proxybench"
	FeatureTrafficLog           = "trafficlog"
	FeatureNoBorda              = "noborda"
	FeatureProbeProxies         = "probeproxies"
	FeatureShortcut             = "shortcut"
	FeatureDetour               = "detour"
	FeatureNoHTTPSEverywhere    = "nohttpseverywhere"
	FeatureReplica              = globalConfig.FeatureReplica
	FeatureProxyWhitelistedOnly = "proxywhitelistedonly"
	FeatureTrackYouTube         = "trackyoutube"
	FeatureGoogleSearchAds      = "googlesearchads"
	FeatureChat                 = "chat"
	FeatureOtel                 = "otel"
	FeatureInterstitialAds      = "interstitialads"
	FeatureTapsellAds           = "tapsellads"
)

Variables

View Source
var (

	// DefaultGlobalConfigPollInterval determines how frequently to fetch global.yaml
	DefaultGlobalConfigPollInterval = 1 * time.Hour
)

Functions

func ForceCountry

func ForceCountry(countryCode string)

ForceCountry forces config fetches to pretend client is running in the given countryCode (e.g. 'cn')

func Init

func Init(
	configDir string, flags map[string]interface{}, userConfig common.UserConfig,
	origGlobalDispatch func(interface{}, Source), onGlobalSaveError func(error),
	rt http.RoundTripper) (stop func())

Init determines the URLs at which to fetch global config and passes those to InitWithURLs, which initializes the config setup for fetching the global config. It returns a function that can be used to stop the reading of configs.

func InitWithURLs

func InitWithURLs(
	configDir string, flags map[string]interface{}, userConfig common.UserConfig,
	origGlobalDispatch func(interface{}, Source), onGlobalSaveError func(error),
	globalURL string, rt http.RoundTripper,
) (stop func())

InitWithURLs initializes the config setup for fetching the global config from the given URL. It returns a function that can be used to stop the reading of configs.

Types

type AdProvider

type AdProvider struct {
	AdSettings
}

func (*AdProvider) GetInterstitialZoneID

func (p *AdProvider) GetInterstitialZoneID() string

func (*AdProvider) GetNativeBannerZoneID

func (p *AdProvider) GetNativeBannerZoneID() string

func (*AdProvider) GetStandardBannerZoneID

func (p *AdProvider) GetStandardBannerZoneID() string

func (*AdProvider) ShouldShowAd

func (p *AdProvider) ShouldShowAd() bool

type AdSettings

type AdSettings struct {
	NativeBannerZoneID   string `yaml:"nativebannerzoneid,omitempty"`
	StandardBannerZoneID string `yaml:"standardbannerzoneid,omitempty"`
	InterstitialZoneID   string `yaml:"interstitialzoneid,omitempty"`
	DaysToSuppress       int    `yaml:"daystosuppress,omitempty"`
	Percentage           float64
	Countries            map[string]string
}

AdSettings are settings to use when showing ads to Android clients

func (*AdSettings) GetAdProvider

func (s *AdSettings) GetAdProvider(isPro bool, countryCode string, daysSinceInstalled int) *AdProvider

type BootstrapSettings

type BootstrapSettings struct {
	StartupUrl string
}

BootstrapSettings provides access to configuration embedded directly in Lantern installation packages. On OSX, that means data embedded in the Lantern.app app bundle in Lantern.app/Contents/Resources/.lantern.yaml, while on Windows that means data embedded in AppData/Roaming/Lantern/.lantern.yaml. This allows customization embedded in the installer outside of the auto-updated binary that should only be used under special circumstances.

func ReadBootstrapSettings

func ReadBootstrapSettings(configDir string) (*BootstrapSettings, error)

ReadBootstrapSettings reads packaged settings from pre-determined paths on the various OSes.

type ClientConfig

type ClientConfig struct {
	DumpHeaders bool // whether or not to dump headers of requests and responses
	Fronted     *FrontedConfig

	// Legacy masquerade configuration
	// included to test presence for older clients
	MasqueradeSets map[string][]*fronted.Masquerade

	// DNS host-to-ip mappings to bypass DNS when resolving hostnames
	// This only works for direct dials (i.e., domain routing rules that are
	// MustDirect or 'md':
	// https://github.com/getlantern/flashlight/blob/f82d9ab04da841e4a2833783b244948a8daa547e/domainrouting/domainrouting.go#L33
	DNSResolutionMapForDirectDials map[string]string
}

ClientConfig captures configuration information for a Client

func NewClientConfig

func NewClientConfig() *ClientConfig

NewClientConfig creates a new client config with default values.

func (*ClientConfig) FrontedProviders

func (c *ClientConfig) FrontedProviders() map[string]*fronted.Provider

Builds a list of fronted.Providers to use based on the configuration

func (*ClientConfig) Validate

func (c *ClientConfig) Validate() error

Check that this ClientConfig is valid

type ClientGroup

type ClientGroup struct {
	// A label so that the group can be referred to when collecting/analyzing
	// metrics. Better to be unique and meaningful.
	Label string
	// UserFloor and UserCeil defines the range of user IDs so that with
	// precision p, any user ID u satisfies floor*p <= u%p < ceil*p belongs to
	// the group. Precision is expressed in the code and can be changed freely.
	//
	// For example, given floor = 0.1 and ceil = 0.2, it matches user IDs end
	// between 100 and 199 if precision is 1000, and IDs end between 1000 and
	// 1999 if precision is 10000.
	//
	// Range: 0-1. When both are omitted, all users fall within the range.
	UserFloor float64
	UserCeil  float64
	// The application the feature applies to. Defaults to all applications.
	Application string
	// A semantic version range which only Lantern versions falls within is consided.
	// Defaults to all versions.
	VersionConstraints string
	// Comma separated list of platforms the group includes.
	// Defaults to all platforms.
	Platforms string
	// Only include Lantern Free clients.
	FreeOnly bool
	// Only include Lantern Pro clients.
	ProOnly bool
	// Comma separated list of countries the group includes.
	// Defaults to all countries.
	GeoCountries string
	// Random fraction of clients to include from the final set where all other
	// criteria match.
	//
	// Range: 0-1. Defaults to 1.
	Fraction float64
}

ClientGroup represents a subgroup of Lantern clients chosen randomly or based on certain criteria on which features can be selectively turned on.

func (ClientGroup) Includes

func (g ClientGroup) Includes(platform, appName, version string, userID int64, isPro bool, geoCountry string) bool

Includes checks if the ClientGroup includes the user, device and country combination, assuming the group has been validated.

func (ClientGroup) Validate

func (g ClientGroup) Validate() error

Validate checks if the ClientGroup fields are valid and do not conflict with each other.

type Config

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

Config is an interface for getting proxy data saved locally, embedded in the binary, or fetched over the network.

type FeatureOptions

type FeatureOptions = globalConfig.FeatureOptions

type Fetcher

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

Fetcher is an interface for fetching config updates.

type FrontedConfig

type FrontedConfig struct {
	Providers map[string]*ProviderConfig
}

Configuration structure for direct domain fronting

type Global

type Global struct {
	Version       int
	CloudConfigCA string
	// AutoUpdateCA is the CA key to pin for auto-updates.
	AutoUpdateCA          string
	UpdateServerURL       string
	BordaReportInterval   time.Duration
	BordaSamplePercentage float64
	// ReportIssueEmail is the recipient of the email sent when the user
	// reports issue.
	ReportIssueEmail string

	// AdSettings are the settings to use for showing ads to mobile clients
	AdSettings *AdSettings

	Client *ClientConfig

	// ProxiedSites are domains that get routed through Lantern rather than accessed directly.
	// This has been deprecated in favor of more precise DomainRoutingRules (see below).
	// The client will continue to honor ProxiedSites configuration for now.
	ProxiedSites *domainrouting.ProxiedSitesConfig

	// DomainRoutingRules specifies routing rules for specific domains, such as forcing proxing, forcing direct dials, etc.
	DomainRoutingRules domainrouting.RulesMap

	// NamedDomainRoutingRules specifies routing rules for specific domains, grouped by name.
	NamedDomainRoutingRules map[string]domainrouting.RulesMap

	// TrustedCAs are trusted CAs for domain fronting domains only.
	TrustedCAs []*fronted.CA

	// GlobalConfigPollInterval sets interval at which to poll for global config
	GlobalConfigPollInterval time.Duration

	// ProxyConfigPollInterval sets interval at which to poll for proxy config
	ProxyConfigPollInterval time.Duration

	// FeaturesEnabled specifies which optional feature is enabled for certain
	// groups of clients.
	FeaturesEnabled map[string][]*ClientGroup
	// FeatureOptions is a generic way to specify options for optional
	// features. It's up to the feature code to handle the raw JSON message.
	FeatureOptions map[string]map[string]interface{}

	// Market share data used by the simbrowser package when picking a browser to simulate.
	GlobalBrowserMarketShareData   simbrowser.MarketShareData
	RegionalBrowserMarketShareData map[simbrowser.CountryCode]simbrowser.MarketShareData

	// Configuration for OpenTelemetry
	Otel *otel.Config
}

Global contains general configuration for Lantern either set globally via the cloud, in command line flags, or in local customizations during development.

func GetEmbeddedGlobalSansTemplateData

func GetEmbeddedGlobalSansTemplateData() (*Global, error)

Returns the global config in structured form, by executing the template without any data. This is useful for consuming parts of the config that aren't templatized.

func NewGlobal

func NewGlobal() *Global

NewGlobal creates a new global config with otherwise nil values set.

func NewGlobalOnDisk added in v7.6.153

func NewGlobalOnDisk(configDir string, flags map[string]interface{}) (*Global, error)

NewGlobalOnDisk creates a new global config that is saved on disk either via the embedded config or fetched from the network.

func (*Global) FeatureEnabled

func (cfg *Global) FeatureEnabled(feature, platform, appName, version string, userID int64, isPro bool,
	geoCountry string) bool

FeatureEnabled checks if the feature is enabled given the client properties.

func (*Global) FeatureEnabledWithLabel

func (cfg *Global) FeatureEnabledWithLabel(feature, platform, appName, version string, userID int64, isPro bool,
	geoCountry string) (enabled bool, label string)

FeatureEnabledWithLabel is the same as FeatureEnabled but also returns the label of the first matched ClientGroup if the feature is enabled.

func (*Global) TrustedCACerts

func (cfg *Global) TrustedCACerts() (pool *x509.CertPool, err error)

TrustedCACerts returns a certificate pool containing the TrustedCAs from this config.

func (*Global) UnmarshalFeatureOptions

func (cfg *Global) UnmarshalFeatureOptions(feature string, opts FeatureOptions) error

type GoogleSearchAdsOptions

type GoogleSearchAdsOptions struct {
	Pattern     string                 `mapstructure:"pattern"`
	BlockFormat string                 `mapstructure:"block_format"`
	AdFormat    string                 `mapstructure:"ad_format"`
	Partners    map[string][]PartnerAd `mapstructure:"partners"`
}

func (*GoogleSearchAdsOptions) FromMap

func (o *GoogleSearchAdsOptions) FromMap(m map[string]interface{}) error

type PartnerAd

type PartnerAd struct {
	Name        string
	URL         string
	Campaign    string
	Description string
	Keywords    []*regexp.Regexp
	Probability float32
}

type ProviderConfig

type ProviderConfig struct {
	HostAliases         map[string]string
	TestURL             string
	Masquerades         []*fronted.Masquerade
	Validator           *ValidatorConfig
	PassthroughPatterns []string
	FrontingSNIs        map[string]*fronted.SNIConfig
	VerifyHostname      *string `yaml:"verifyHostname,omitempty"`
}

Configuration structure for a particular fronting provider (cloudfront, akamai, etc)

func (*ProviderConfig) GetResponseValidator

func (p *ProviderConfig) GetResponseValidator(providerID string) fronted.ResponseValidator

returns a fronted.ResponseValidator specified by the provider config or nil if none was specified

type Source

type Source string

Source specifies where the config is from when dispatching.

const (
	Saved    Source = "saved"
	Embedded Source = "embedded"
	Fetched  Source = "fetched"
)

type TrafficLogOptions

type TrafficLogOptions struct {
	// Size of the traffic log's packet buffers (if enabled).
	CaptureBytes int
	SaveBytes    int

	// How far back to go when attaching packets to an issue report.
	CaptureSaveDuration time.Duration

	// Whether to overwrite the traffic log binary. This may result in users being re-prompted for
	// their passwords. The binary will never be overwritten if the existing binary matches the
	// embedded version.
	Reinstall bool

	// The minimum amount of time to wait before re-prompting the user since the last time we failed
	// to install the traffic log. The most likely reason for a failed install is denial of
	// permission by the user. A value of 0 means we never re-attempt installation.
	WaitTimeSinceFailedInstall time.Duration

	// The number of times installation can fail before we give up on this client. A value of zero
	// is equivalent to a value of one.
	FailuresThreshold int

	// After this amount of time has elapsed, the failure count is reset and a user may be
	// re-prompted to install the traffic log.
	TimeBeforeFailureReset time.Duration

	// The number of times a user must deny permission for the traffic log before we stop asking. A
	// value of zero is equivalent to a value of one.
	UserDenialThreshold int

	// After this amount of time has elapsed, the user denial count is reset and a user may be
	// re-prompted to install the traffic log.
	TimeBeforeDenialReset time.Duration
}

TrafficLogOptions represents options for github.com/getlantern/trafficlog-flashlight.

func (*TrafficLogOptions) FromMap

func (o *TrafficLogOptions) FromMap(m map[string]interface{}) error

type ValidatorConfig

type ValidatorConfig struct {
	RejectStatus []int
}

Configuration struture that specifies a fronted.ResponseValidator

Directories

Path Synopsis
This program is a simple config checker tool for proxies and global configs.
This program is a simple config checker tool for proxies and global configs.
This package breaks out some global config handling to where it can be used externally without dependence on all flashlight config.
This package breaks out some global config handling to where it can be used externally without dependence on all flashlight config.
Package userconfig provides a simple way to manage client configuration.
Package userconfig provides a simple way to manage client configuration.

Jump to

Keyboard shortcuts

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