Documentation
¶
Index ¶
- Variables
- func LoconfScanner(settings *Settings, configDir string, interval time.Duration, ...) (stop func())
- func NewStatsTracker() *statsTracker
- type App
- func (app *App) AddExitFunc(label string, exitFunc func())
- func (app *App) AuthClient() auth.AuthClient
- func (app *App) Connect()
- func (app *App) Disconnect()
- func (app *App) Exit(err error) bool
- func (app *App) FetchUserData() error
- func (app *App) GetDeviceID() (string, error)
- func (app *App) GetHasConfigFetched() bool
- func (app *App) GetHasProxyFetched() bool
- func (app *App) GetLanguage() string
- func (app *App) GetOnSuccess() bool
- func (app *App) GetUserFirstVisit() (bool, error)
- func (app *App) HasSucceedingProxy() bool
- func (app *App) IsFeatureEnabled(feature string) bool
- func (app *App) IsPro() bool
- func (app *App) IsProUser(ctx context.Context, uc common.UserConfig) (bool, bool)
- func (app *App) IsProUserFast() (isPro bool, statusKnown bool)
- func (app *App) IsUserLoggedIn() 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) ProClient() proclient.ProClient
- func (app *App) ProxyAddrReachable(ctx context.Context) error
- func (app *App) RefreshUserData() (*protos.User, error)
- func (app *App) Run(ctx context.Context) error
- func (app *App) SendConfig()
- func (app *App) SendMessageToUI(service string, message interface{})
- func (app *App) SetEmailAddress(email string) error
- func (app *App) SetExpiration(exp int64) error
- func (app *App) SetLanguage(lang string)
- func (app *App) SetProUser(pro bool) error
- func (app *App) SetReferralCode(referral string) error
- func (app *App) SetUserData(ctx context.Context, userID int64, u *protos.User)
- func (app *App) SetUserDevices(userID int64, devices []*protos.Device)
- func (app *App) SetUserIDAndToken(id int64, token string) error
- func (app *App) SetUserLoggedIn(value bool)
- func (app *App) Settings() *Settings
- func (app *App) Stats() stats.Stats
- func (app *App) SysProxyOff() error
- func (app *App) SysproxyOn() error
- func (app *App) UserConfig() common.UserConfig
- func (app *App) UserData(args ...int64) (*protos.User, bool)
- 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) GetDisconnected() bool
- func (s *Settings) GetEmailAddress() string
- func (s *Settings) GetEnabledExperiments() []string
- func (s *Settings) GetExpirationDate() 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) GetPastAnnouncements() []string
- func (s *Settings) GetProxyAll() bool
- func (s *Settings) GetReferralCode() string
- func (s *Settings) GetSOCKSAddr() string
- func (s *Settings) GetSalt() []byte
- 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) GetUserFirstVisit() bool
- func (s *Settings) GetUserID() int64
- func (s *Settings) IsAutoLaunch() bool
- func (s *Settings) IsAutoReport() bool
- func (s *Settings) IsProUser() bool
- func (s *Settings) IsUserLoggedIn() bool
- func (s *Settings) Locale() string
- func (s *Settings) OnChange(attr SettingName, cb func(interface{}))
- func (s *Settings) SaveSalt(salt []byte)
- func (s *Settings) SetAddr(addr string)
- func (s *Settings) SetCountry(country string)
- func (s *Settings) SetDisconnected(disconnected bool)
- func (s *Settings) SetEmailAddress(email string)
- func (s *Settings) SetEnabledExperiments(ex []string)
- func (s *Settings) SetExpiration(expiration int64)
- func (s *Settings) SetExpirationDate(date 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) SetPastAnnouncements(announcements []string)
- func (s *Settings) SetProUser(value bool)
- func (s *Settings) SetProxyAll(proxyAll bool)
- func (s *Settings) SetReferralCode(referralCode string)
- func (s *Settings) SetSOCKSAddr(addr string)
- func (s *Settings) SetTakenSurveys(campaigns []string)
- func (s *Settings) SetUIAddr(uiaddr string)
- func (s *Settings) SetUserFirstVisit(value bool)
- func (s *Settings) SetUserIDAndToken(id int64, token string)
- func (s *Settings) SetUserLoggedIn(value bool)
- func (s *Settings) StartService(channel ws.UIChannel) error
- type Tab
Constants ¶
This section is empty.
Variables ¶
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() *statsTracker
Types ¶
type App ¶
type App struct {
Flags flashlight.Flags // Command-line flags passed to the app.
// contains filtered or unexported fields
}
App is the core of the Lantern desktop application, managing components and configurations.
func NewApp ¶
NewApp creates a new desktop app that initializes the app and acts as a moderator between all desktop components.
func NewAppWithFlags ¶
func NewAppWithFlags(flags flashlight.Flags, configDir string) (*App, error)
NewAppWithFlags creates a new App instance with the given flags and configuration directory.
func (*App) AddExitFunc ¶
AddExitFunc adds a function to be called before the application exits.
func (*App) AuthClient ¶
func (app *App) AuthClient() auth.AuthClient
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) FetchUserData ¶
Client session methods this method get call when user is being created first time
func (*App) GetDeviceID ¶
func (*App) GetHasConfigFetched ¶
func (*App) GetHasProxyFetched ¶
func (*App) GetLanguage ¶
GetLanguage returns the user language
func (*App) GetOnSuccess ¶
func (*App) GetUserFirstVisit ¶
func (*App) HasSucceedingProxy ¶
HasSucceedingProxy returns whether or not the app is currently configured with any succeeding proxies
func (*App) IsFeatureEnabled ¶
IsFeatureEnabled checks whether or not the given feature is enabled by flashlight
func (*App) IsProUserFast ¶
IsProUserFast indicates whether or not the user is pro and whether or not the user's status is know, never calling the Pro API to determine the status.
func (*App) IsUserLoggedIn ¶
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) ProxyAddrReachable ¶
ProxyAddrReachable checks if Lantern's HTTP proxy responds with the correct status within the deadline.
func (*App) Run ¶
Run creates a new instance of App, initializes necessary components, and starts running the application.
func (*App) SendConfig ¶
func (app *App) SendConfig()
func (*App) SendMessageToUI ¶
Create func that send message to UI
func (*App) SetEmailAddress ¶
func (*App) SetExpiration ¶
func (*App) SetLanguage ¶
SetLanguage sets the user language
func (*App) SetProUser ¶
func (*App) SetReferralCode ¶
func (*App) SetUserData ¶
SetUserData stores the user data in the cache
func (*App) SetUserDevices ¶
SetUserDevices updates the list of devices associated with a user in the cache.
func (*App) SetUserLoggedIn ¶
func (*App) SysProxyOff ¶
func (*App) SysproxyOn ¶
func (*App) UserConfig ¶
func (app *App) UserConfig() common.UserConfig
UserConfig returns the current user configuration after applying settings.
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" SNUserPro SettingName = "userPro" SNReferralCode SettingName = "referralCode" 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" // Auth methods SNUserFirstVisit SettingName = "userFirstVisit" SNExpiryDate SettingName = "expirydate" SNUserLoggedIn SettingName = "userLoggedIn" SNSalt SettingName = "salt" )
type Settings ¶
Settings is a struct of all settings unique to this particular Lantern instance.
func LoadSettings ¶
LoadSettings loads the initial settings at startup, either from disk or using defaults.
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) GetDisconnected ¶
GetDisconnected returns whether or not we're disconnected
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) GetExpirationDate ¶
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) GetPastAnnouncements ¶
GetPastAnnouncements returns past campaign announcements
func (*Settings) GetProxyAll ¶
GetProxyAll returns whether or not to proxy all traffic.
func (*Settings) GetReferralCode ¶
GetReferralCode returns the user referral code
func (*Settings) GetSOCKSAddr ¶
GetSOCKSAddr returns the SOCKS proxy address.
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) GetUserFirstVisit ¶
GetUserFirstVisit returns the user's first visit flag
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) IsUserLoggedIn ¶
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) SetDisconnected ¶
SetDisconnected sets whether or not we're disconnected
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) SetExpiration ¶
func (*Settings) SetExpirationDate ¶
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) SetPastAnnouncements ¶
SetPastAnnouncements sets past campaigns announcements
func (*Settings) SetProUser ¶
func (*Settings) SetProxyAll ¶
SetProxyAll sets whether or not to proxy all traffic.
func (*Settings) SetReferralCode ¶
SetReferralCode sets the user referral code
func (*Settings) SetSOCKSAddr ¶
SetSOCKSAddr sets the SOCKS proxy address.
func (*Settings) SetTakenSurveys ¶
SetTakenSurveys sets the IDs of taken surveys.
func (*Settings) SetUserFirstVisit ¶
Auth methods SetUserFirstVisit sets the user's first visit flag
func (*Settings) SetUserIDAndToken ¶
SetUserIDAndToken sets the user ID and token atomically