Documentation ¶
Index ¶
- Constants
- Variables
- func AddCommonHeaders(uc UserConfig, req *http.Request)
- func AddCommonHeadersWithOptions(uc UserConfig, req *http.Request, overwriteAuth bool)
- func AddCommonNonUserHeaders(uc UserConfig, req *http.Request)
- func CORSMiddleware(next http.Handler) http.Handler
- func ForceAds() bool
- func ForceStaging()
- func IsDevEnvironment() bool
- func IsStagingEnvironment() bool
- func ProcessCORS(responseHeaders http.Header, r *http.Request) bool
- type AuthConfig
- type Environment
- type UserConfig
- type UserConfigData
- func (uc *UserConfigData) GetAppName() string
- func (uc *UserConfigData) GetDeviceID() string
- func (uc *UserConfigData) GetEnabledExperiments() []string
- func (uc *UserConfigData) GetInternalHeaders() map[string]string
- func (uc *UserConfigData) GetLanguage() string
- func (uc *UserConfigData) GetTimeZone() (string, error)
- func (uc *UserConfigData) GetToken() string
- func (uc *UserConfigData) GetUserID() int64
- func (uc *UserConfigData) Locale() string
Constants ¶
const ( // ProxiesURL is the URL for fetching the per user proxy config. ProxiesURL = "http://config.getiantem.org/proxies.yaml.gz" // ProxiesStagingURL is the URL for fetching the per user proxy config in a staging environment. ProxiesStagingURL = "http://config-staging.getiantem.org/proxies.yaml.gz" // Sentry Configurations SentryTimeout = time.Second * 30 SentryMaxMessageChars = 8000 // UpdateServerURL is the URL of the update server. Different applications // hit the server on separate paths "/update/<AppName>". UpdateServerURL = "https://update.getlantern.org" )
const ( AppHeader = "X-Lantern-App" LibraryVersionHeader = "X-Lantern-Version" AppVersionHeader = "X-Lantern-App-Version" DeviceIdHeader = "X-Lantern-Device-Id" SupportedDataCapsHeader = "X-Lantern-Supported-Data-Caps" TimeZoneHeader = "X-Lantern-Time-Zone" TokenHeader = "X-Lantern-Auth-Token" UserIdHeader = "X-Lantern-User-Id" ProTokenHeader = "X-Lantern-Pro-Token" CfgSvrAuthTokenHeader = "X-Lantern-Config-Auth-Token" CfgSvrClientIPHeader = "X-Lantern-Config-Client-IP" BBRBytesSentHeader = "X-BBR-Sent" BBRAvailableBandwidthEstimateHeader = "X-BBR-ABE" EtagHeader = "X-Lantern-Etag" KernelArchHeader = "X-Lantern-KernelArch" IfNoneMatchHeader = "X-Lantern-If-None-Match" PingHeader = "X-Lantern-Ping" PlatformHeader = "X-Lantern-Platform" PlatformVersionHeader = "X-Lantern-PlatVer" ClientCountryHeader = "X-Lantern-Client-Country" RandomNoiseHeader = "X-Lantern-Rand" SleepHeader = "X-Lantern-Sleep" LocaleHeader = "X-Lantern-Locale" Referer = "Referer" XBQHeader = "XBQ" XBQHeaderv2 = "XBQv2" ContentType = "Content-Type" )
const ( // The default name for this app (used if no client-supplied name is passed at initialization) DefaultAppName = "Lantern" // ProAvailable specifies whether the user can purchase pro with this version. ProAvailable = true // TrackingID is the Google Analytics tracking ID. TrackingID = "UA-21815217-12" // SentryDSN is Sentry's project ID thing SentryDSN = "https://f65aa492b9524df79b05333a0b0924c5@sentry.io/2222244" // SentryDSN is Sentry's for android project SentrtAndroidDSN = "https://4753d78f885f4b79a497435907ce4210@o75725.ingest.us.sentry.io/5850353" )
const Platform = runtime.GOOS
Variables ¶
var ( // EnvMapping is a mapping for the Environment enum EnvMapping = map[string]Environment{ Development.String(): Development, Production.String(): Production, Staging.String(): Staging, } // DisablePort is a boolean flag that corresponds with the DISABLE_PORT_RANDOMIZATION env var DisablePort bool )
var ( EnvironmentDevelopment = "development" EnvironmentProduction = "production" )
var ( // GlobalURL URL for fetching the global config. GlobalURL = "https://globalconfig.flashlightproxy.com/global.yaml.gz" // GlobalStagingURL is the URL for fetching the global config in a staging environment. GlobalStagingURL = "https://globalconfig.flashlightproxy.com/global.yaml.gz" ProAPIHost = "api.getiantem.org" DFBaseUrl = "df.iantem.io/api/v1" APIBaseUrl = "iantem.io/api/v1" )
var ( // ApplicationVersion is set at compile-time by application production builds ApplicationVersion string = "9999.99.99" // LibraryVersion is determined at runtime based on the version of the lantern library that's been included. LibraryVersion = "" // This gets set at build time RevisionDate = "" // This gets set at build time BuildDate = "" )
Functions ¶
func AddCommonHeaders ¶
func AddCommonHeaders(uc UserConfig, req *http.Request)
AddCommonHeaders sets standard http headers on a request bound for an internal service, representing auth and other configuration metadata.
func AddCommonHeadersWithOptions ¶
func AddCommonHeadersWithOptions(uc UserConfig, req *http.Request, overwriteAuth bool)
AddCommonHeadersWithOptions sets standard http headers on a request bound for an internal service, representing auth and other configuration metadata. The caller may specify overwriteAuth=false to prevent overwriting any of the common 'auth' headers (DeviceIdHeader, ProTokenHeader, UserIdHeader) that are already present in the given request.
func AddCommonNonUserHeaders ¶
func AddCommonNonUserHeaders(uc UserConfig, req *http.Request)
AddCommonNonUserHeaders adds all common headers that are not user or device specific.
func CORSMiddleware ¶
CORSMiddleware is HTTP middleware used to process CORS requests on localhost
func IsDevEnvironment ¶
func IsDevEnvironment() bool
IsDevEnvironment checks if flashlight is currently being run in development mode
func IsStagingEnvironment ¶
func IsStagingEnvironment() bool
IsDevEnvironment checks if flashlight is currently being run in staging mode
Types ¶
type AuthConfig ¶
type AuthConfig interface { GetAppName() string GetDeviceID() string GetUserID() int64 GetToken() string Locale() string }
AuthConfig retrieves any custom info for interacting with internal services.
type Environment ¶
type Environment int
Environment represents different environments Lantern may be running in
const ( Development Environment = iota Production Staging )
func (Environment) IsDevelopment ¶
func (e Environment) IsDevelopment() bool
IsDevelopment checks if flashlight is currently being run in dev mode
func (Environment) IsStaging ¶
func (e Environment) IsStaging() bool
IsStaging checks if flashlight is currently being run in staging mode
func (Environment) String ¶
func (e Environment) String() string
type UserConfig ¶
type UserConfigData ¶
type UserConfigData struct { AppName string DeviceID string UserID int64 Token string Language string Headers map[string]string }
an implementation of UserConfig
func NewUserConfig ¶
func NewUserConfig(appName string, deviceID string, userID int64, token string, headers map[string]string, lang string) *UserConfigData
NewUserConfig constucts a new UserConfigData with the given options.
func (*UserConfigData) GetAppName ¶
func (uc *UserConfigData) GetAppName() string
func (*UserConfigData) GetDeviceID ¶
func (uc *UserConfigData) GetDeviceID() string
func (*UserConfigData) GetEnabledExperiments ¶
func (uc *UserConfigData) GetEnabledExperiments() []string
func (*UserConfigData) GetInternalHeaders ¶
func (uc *UserConfigData) GetInternalHeaders() map[string]string
func (*UserConfigData) GetLanguage ¶
func (uc *UserConfigData) GetLanguage() string
func (*UserConfigData) GetTimeZone ¶
func (uc *UserConfigData) GetTimeZone() (string, error)
func (*UserConfigData) GetToken ¶
func (uc *UserConfigData) GetToken() string
func (*UserConfigData) GetUserID ¶
func (uc *UserConfigData) GetUserID() int64
func (*UserConfigData) Locale ¶
func (uc *UserConfigData) Locale() string