Documentation ¶
Index ¶
- Variables
- func LoconfScanner(settings *Settings, configDir string, interval time.Duration, ...) (stop func())
- func NewStatsTracker(app *App) *statsTracker
- func ShouldReportToSentry() bool
- type App
- func (app *App) AdTrackURL() string
- func (app *App) AddExitFunc(label string, exitFunc func())
- func (app *App) AddToken(path string) string
- func (app *App) Connect()
- func (app *App) Disconnect()
- func (app *App) Exit(err error) bool
- func (app *App) GetLanguage() string
- func (app *App) GetTranslations(filename string) ([]byte, error)
- func (app *App) IsPro() bool
- func (app *App) IsProUser() (isPro bool, ok bool)
- func (app *App) IsSysProxyOn() bool
- func (app *App) LogPanicAndExit(msg string)
- func (app *App) OnSettingChange(attr SettingName, cb func(interface{}))
- func (app *App) OnStatsChange(fn func(stats.Stats))
- func (app *App) OnTrayShow()
- func (app *App) OnTrayUpgrade()
- func (app *App) PlansURL() string
- func (app *App) ProxyAddrReachable(ctx context.Context) error
- func (app *App) ReferralCode(uc common.UserConfig) (string, error)
- func (app *App) Run(isMain bool)
- func (app *App) SelectedTab() Tab
- func (app *App) SetLanguage(lang string)
- func (app *App) SetReferralCode(referralCode string)
- func (app *App) SetSelectedTab(selectedTab Tab)
- func (app *App) SetStats(st *stats.Stats)
- func (app *App) SetSysProxy(_sysproxyOff func() error)
- func (app *App) Settings() *Settings
- func (app *App) Stats() *stats.Stats
- func (app *App) SysProxyOff() (err error)
- func (app *App) SysproxyOn() (err error)
- func (app *App) WaitForExit() error
- func (app *App) WebsocketAddr() string
- type SettingName
- type Settings
- func (s *Settings) GetAddr() string
- func (s *Settings) GetAppName() string
- func (s *Settings) GetCountry() string
- func (s *Settings) GetDeviceID() string
- func (s *Settings) GetEmailAddress() string
- func (s *Settings) GetEnabledExperiments() []string
- func (s *Settings) GetGoogleAds() bool
- func (s *Settings) GetInt64Eventually(name SettingName) (int64, error)
- func (s *Settings) GetInternalHeaders() map[string]string
- func (s *Settings) GetLanguage() string
- func (s *Settings) GetLocalHTTPToken() string
- func (s *Settings) GetMigratedDeviceIDForUserID() int64
- func (s *Settings) GetProxyAll() bool
- func (s *Settings) GetSystemProxy() bool
- func (s *Settings) GetTakenSurveys() []string
- func (s *Settings) GetTimeZone() (string, error)
- func (s *Settings) GetToken() string
- func (s *Settings) GetUIAddr() string
- func (s *Settings) GetUserID() int64
- func (s *Settings) IsAutoLaunch() bool
- func (s *Settings) IsAutoReport() bool
- func (s *Settings) OnChange(attr SettingName, cb func(interface{}))
- func (s *Settings) SetCountry(country string)
- func (s *Settings) SetEmailAddress(email string)
- func (s *Settings) SetEnabledExperiments(ex []string)
- func (s *Settings) SetGoogleAds(g bool)
- func (s *Settings) SetLanguage(language string)
- func (s *Settings) SetLocalHTTPToken(token string)
- func (s *Settings) SetMigratedDeviceIDForUserID(userID int64)
- func (s *Settings) SetProxyAll(proxyAll bool)
- func (s *Settings) SetTakenSurveys(campaigns []string)
- func (s *Settings) SetUIAddr(uiaddr string)
- func (s *Settings) SetUserIDAndToken(id int64, token string)
- func (s *Settings) StartService(channel ws.UIChannel) error
- type Tab
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingTab = errors.New("missing tab") AccountTab = Tab("account") DeveloperTab = Tab("developer") VPNTab = Tab("vpn") UnknownTab = Tab("") )
var ( // This gets set at build time ApplicationVersion = "9999.99.99" // This gets set at build time RevisionDate = "" // This gets set at build time BuildDate = "" )
Functions ¶
func LoconfScanner ¶
func LoconfScanner(settings *Settings, configDir string, interval time.Duration, proChecker func() (bool, bool), iconURL func() string) (stop func())
LoconfScanner starts a goroutine to periodically check for new loconf files. This will show announcements via desktop notification. Each announcement is shown only once. It will also do things like check for updates to uninstall survey config
interval: The duration between each check.
proChecker: A function to check if current user is Pro (to decide whether show the announcement or not).
Returns a function to stop the loop.
func NewStatsTracker ¶
func NewStatsTracker(app *App) *statsTracker
func ShouldReportToSentry ¶
func ShouldReportToSentry() bool
ShouldReportToSentry determines if we should report errors/panics to Sentry
Types ¶
type App ¶
type App struct { Flags flashlight.Flags // contains filtered or unexported fields }
App is the core of the Lantern desktop application, in the form of a library.
func NewApp ¶
func NewApp(flags flashlight.Flags, configDir string, proClient *client.Client, settings *Settings) *App
NewApp creates a new desktop app that initializes the app and acts as a moderator between all desktop components.
func (*App) AdTrackURL ¶
AdTrackURL returns the URL for adding tracking on injected ads.
func (*App) AddExitFunc ¶
AddExitFunc adds a function to be called before the application exits.
func (*App) Exit ¶
Exit tells the application to exit, optionally supplying an error that caused the exit. Returns true if the app is actually exiting, false if exit has already been requested.
func (*App) GetLanguage ¶
GetLanguage returns the user language
func (*App) GetTranslations ¶
GetTranslations accesses translations with the given filename
func (*App) IsProUser ¶
isProUser blocks itself to check if current user is Pro, or !ok if error happens getting user status from pro-server. The result is not cached because the user can become Pro or free at any time. It waits until the user ID becomes non-zero.
func (*App) IsSysProxyOn ¶
func (*App) LogPanicAndExit ¶
is only used in the panicwrap parent process.
func (*App) OnSettingChange ¶
func (app *App) OnSettingChange(attr SettingName, cb func(interface{}))
OnSettingChange sets a callback cb to get called when attr is changed from server. When calling multiple times for same attr, only the last one takes effect.
func (*App) OnStatsChange ¶
OnStatsChange adds a listener for Stats changes.
func (*App) OnTrayShow ¶
func (app *App) OnTrayShow()
OnTrayShow indicates the user has selected to show lantern from the tray.
func (*App) OnTrayUpgrade ¶
func (app *App) OnTrayUpgrade()
OnTrayUpgrade indicates the user has selected to upgrade lantern from the tray.
func (*App) ProxyAddrReachable ¶
ProxyAddrReachable checks if Lantern's HTTP proxy responds with the correct status within the deadline.
func (*App) ReferralCode ¶
func (app *App) ReferralCode(uc common.UserConfig) (string, error)
ReferralCode returns a user's unique referral code
func (*App) SelectedTab ¶
func (*App) SetLanguage ¶
SetLanguage sets the user language
func (*App) SetReferralCode ¶
func (*App) SetSelectedTab ¶
func (*App) SetSysProxy ¶
func (*App) SysProxyOff ¶
func (*App) SysproxyOn ¶
func (*App) WaitForExit ¶
WaitForExit waits for a request to exit the application.
func (*App) WebsocketAddr ¶
type SettingName ¶
type SettingName string
SettingName is the name of a setting.
const ( SNAutoReport SettingName = "autoReport" SNAutoLaunch SettingName = "autoLaunch" SNProxyAll SettingName = "proxyAll" SNGoogleAds SettingName = "googleAds" SNSystemProxy SettingName = "systemProxy" SNDisconnected SettingName = "disconnected" SNLanguage SettingName = "lang" SNCountry SettingName = "country" SNLocalHTTPToken SettingName = "localHTTPToken" SNDeviceID SettingName = "deviceID" SNEmailAddress SettingName = "emailAddress" SNUserID SettingName = "userID" SNUserToken SettingName = "userToken" SNMigratedDeviceIDForUserID SettingName = "migratedDeviceIDForUserID" SNTakenSurveys SettingName = "takenSurveys" SNPastAnnouncements SettingName = "pastAnnouncements" SNAddr SettingName = "addr" SNSOCKSAddr SettingName = "socksAddr" SNUIAddr SettingName = "uiAddr" SNVersion SettingName = "version" SNBuildDate SettingName = "buildDate" SNRevisionDate SettingName = "revisionDate" SNEnabledExperiments SettingName = "enabledExperiments" )
type Settings ¶
Settings is a struct of all settings unique to this particular Lantern instance.
func LoadSettingsFrom ¶
func (*Settings) GetAppName ¶
func (*Settings) GetCountry ¶
GetCountry returns the user country
func (*Settings) GetDeviceID ¶
GetDeviceID returns the unique ID of this device.
func (*Settings) GetEmailAddress ¶
GetEmailAddress gets the email address of pro users.
func (*Settings) GetEnabledExperiments ¶
GetEnabledExperiments returns the names of the Lantern experiment IDs that were enabled via flags.
func (*Settings) GetGoogleAds ¶
GetGoogleAds returns whether or not to proxy all traffic.
func (*Settings) GetInt64Eventually ¶
func (s *Settings) GetInt64Eventually(name SettingName) (int64, error)
GetInt64Eventually blocks returning an int64 until the int has a value other than the defualt.
func (*Settings) GetInternalHeaders ¶
GetInternalHeaders returns extra headers sent with requests to internal services
func (*Settings) GetLanguage ¶
GetLanguage returns the user language
func (*Settings) GetLocalHTTPToken ¶
GetLocalHTTPToken returns the local HTTP token.
func (*Settings) GetMigratedDeviceIDForUserID ¶
GetMigratedDeviceIDForUserID returns the user ID (if any) for which the current device's ID has been migrated from the old style to the new style
func (*Settings) GetProxyAll ¶
GetProxyAll returns whether or not to proxy all traffic.
func (*Settings) GetSystemProxy ¶
GetSystemProxy returns whether or not to set system proxy when lantern starts
func (*Settings) GetTakenSurveys ¶
GetTakenSurveys returns the IDs of surveys the user has already taken.
func (*Settings) GetTimeZone ¶
func (*Settings) GetUIAddr ¶
GetUIAddr returns the address of the UI, stored across runs to avoid a different port on each run, which breaks things like local storage in the UI.
func (*Settings) IsAutoLaunch ¶
IsAutoLaunch returns whether or not to automatically launch on system startup.
func (*Settings) IsAutoReport ¶
IsAutoReport returns whether or not to auto-report debugging and analytics data.
func (*Settings) OnChange ¶
func (s *Settings) OnChange(attr SettingName, cb func(interface{}))
OnChange sets a callback cb to get called when attr is changed from UI.
func (*Settings) SetCountry ¶
SetCountry sets the user's country.
func (*Settings) SetEmailAddress ¶
SetEmailAddress locally stores the email address of a pro user
func (*Settings) SetEnabledExperiments ¶
SetEnabledExperiments sets the Lantern experiment IDs that were enabled via flags.
func (*Settings) SetGoogleAds ¶
SetGoogleAds sets whether or not to proxy all traffic.
func (*Settings) SetLanguage ¶
SetLanguage sets the user language
func (*Settings) SetLocalHTTPToken ¶
SetLocalHTTPToken sets the local HTTP token, stored on disk because we've seen weird issues on Windows where the OS remembers old, inactive PAC URLs with old tokens and uses them, breaking Edge and IE.
func (*Settings) SetMigratedDeviceIDForUserID ¶
SetMigratedDeviceIDForUserID stores the user ID (if any) for which the current device's ID has been migrated from the old style to the new style
func (*Settings) SetProxyAll ¶
SetProxyAll sets whether or not to proxy all traffic.
func (*Settings) SetTakenSurveys ¶
SetTakenSurveys sets the IDs of taken surveys.
func (*Settings) SetUserIDAndToken ¶
SetUserIDAndToken sets the user ID and token atomically