Documentation ¶
Index ¶
- Constants
- Variables
- func ForceCountry(countryCode string)
- func Init(configDir string, flags map[string]interface{}, userConfig common.UserConfig, ...) (stop func())
- func InitWithURLs(configDir string, flags map[string]interface{}, userConfig common.UserConfig, ...) (stop func())
- type AdProvider
- type AdSettings
- type BootstrapSettings
- type ClientConfig
- type ClientGroup
- type Config
- type FeatureOptions
- type Fetcher
- type FrontedConfig
- type Global
- func (cfg *Global) FeatureEnabled(feature, platform, appName, version string, userID int64, isPro bool, ...) bool
- func (cfg *Global) FeatureEnabledWithLabel(feature, platform, appName, version string, userID int64, isPro bool, ...) (enabled bool, label string)
- func (cfg *Global) TrustedCACerts() (pool *x509.CertPool, err error)
- func (cfg *Global) UnmarshalFeatureOptions(feature string, opts FeatureOptions) error
- type GoogleSearchAdsOptions
- type PingProxiesOptions
- type ProviderConfig
- type ReplicaOptions
- type ReplicaOptionsRoot
- type Source
- type TrafficLogOptions
- type ValidatorConfig
Constants ¶
const ( FeatureAuth = "auth" FeatureProxyBench = "proxybench" FeaturePingProxies = "pingproxies" FeatureTrafficLog = "trafficlog" FeatureNoBorda = "noborda" FeatureProbeProxies = "probeproxies" FeatureShortcut = "shortcut" FeatureDetour = "detour" FeatureNoHTTPSEverywhere = "nohttpseverywhere" FeatureReplica = "replica" FeatureProxyWhitelistedOnly = "proxywhitelistedonly" FeatureTrackYouTube = "trackyoutube" FeatureGoogleSearchAds = "googlesearchads" FeatureYinbiWallet = "yinbiwallet" FeatureYinbi = "yinbi" FeatureGoogleAnalytics = "googleanalytics" FeatureMatomo = "matomo" FeatureChat = "chat" )
const ( // for historical reasons, if a provider is unspecified in a masquerade, it // is treated as a cloudfront masquerade (which was once the only provider) DefaultFrontedProviderID = "cloudfront" )
Variables ¶
var ( // DefaultProxyConfigPollInterval determines how frequently to fetch proxies.yaml DefaultProxyConfigPollInterval = 1 * time.Minute // ForceProxyConfigPollInterval overrides how frequently to fetch proxies.yaml if set (does not honor values from global.yaml) ForceProxyConfigPollInterval = 0 * time.Second // 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, proxiesDispatch func(interface{}, Source), onProxiesSaveError func(error), origGlobalDispatch func(interface{}, Source), onGlobalSaveError func(error), rt http.RoundTripper) (stop func())
Init determines the URLs at which to fetch proxy and global config and passes those to InitWithURLs, which initializes the config setup for both fetching per-user proxies as well as 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, origProxiesDispatch func(interface{}, Source), onProxiesSaveError func(error), origGlobalDispatch func(interface{}, Source), onGlobalSaveError func(error), proxyURL string, globalURL string, rt http.RoundTripper) (stop func())
InitWithURLs initializes the config setup for both fetching per-user proxies as well as the global config given a set of URLs for fetching proxy and global config. 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 }
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 interface {
// contains filtered or unexported methods
}
FeatureOptions is an interface implemented by all feature options
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. }
Global contains general configuration for Lantern either set globally via the cloud, in command line flags, or in local customizations during development.
func NewGlobal ¶
func NewGlobal() *Global
NewGlobal creates a new global config with otherwise nil values set.
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 ¶
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 PingProxiesOptions ¶
type ProviderConfig ¶
type ProviderConfig struct { HostAliases map[string]string TestURL string Masquerades []*fronted.Masquerade Validator *ValidatorConfig PassthroughPatterns []string }
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 ReplicaOptions ¶
type ReplicaOptions struct { // Use infohash and old-style prefixing simultaneously for now. Later, the old-style can be removed. WebseedBaseUrls []string Trackers []string StaticPeerAddrs []string // Merged with the webseed URLs when the metadata and data buckets are merged. MetadataBaseUrls []string // The replica-rust endpoint to use. There's only one because object uploads and ownership are // fixed to a specific bucket, and replica-rust endpoints are 1:1 with a bucket. ReplicaRustEndpoint string // A set of info hashes (20 bytes, hex-encoded) to which proxies should announce themselves. ProxyAnnounceTargets []string // A set of info hashes where p2p-proxy peers can be found. ProxyPeerInfoHashes []string }
func (*ReplicaOptions) GetMetadataBaseUrls ¶
func (ro *ReplicaOptions) GetMetadataBaseUrls() []string
func (*ReplicaOptions) GetReplicaRustEndpoint ¶
func (ro *ReplicaOptions) GetReplicaRustEndpoint() string
func (*ReplicaOptions) GetStaticPeerAddrs ¶
func (ro *ReplicaOptions) GetStaticPeerAddrs() []string
func (*ReplicaOptions) GetTrackers ¶
func (ro *ReplicaOptions) GetTrackers() []string
func (*ReplicaOptions) GetWebseedBaseUrls ¶
func (ro *ReplicaOptions) GetWebseedBaseUrls() []string
type ReplicaOptionsRoot ¶
type ReplicaOptionsRoot struct { // This is the default. ReplicaOptions `mapstructure:",squash"` // Options tailored to country. This could be used to pattern match any arbitrary string really. // mapstructure should ignore the field name. ByCountry map[string]ReplicaOptions `mapstructure:",remain"` // Deprecated. An unmatched country uses the embedded ReplicaOptions.ReplicaRustEndpoint. // Removing this will break unmarshalling config. ReplicaRustDefaultEndpoint string // Deprecated. Use ByCountry.ReplicaRustEndpoint. ReplicaRustEndpoints map[string]string }
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.
type ValidatorConfig ¶
type ValidatorConfig struct {
RejectStatus []int
}
Configuration struture that specifies a fronted.ResponseValidator
Source Files ¶
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. |