app

package
v0.0.0-...-22f0dc9 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 68 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingTab = errors.New("missing tab")
	AccountTab    = Tab("account")
	DeveloperTab  = Tab("developer")
	VPNTab        = Tab("vpn")
	UnknownTab    = Tab("")
)
View Source
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

func (app *App) AdTrackURL() string

AdTrackURL returns the URL for adding tracking on injected ads.

func (*App) AddExitFunc

func (app *App) AddExitFunc(label string, exitFunc func())

AddExitFunc adds a function to be called before the application exits.

func (*App) AddToken

func (app *App) AddToken(path string) string

AddToken adds our secure token to a given request path.

func (*App) Connect

func (app *App) Connect()

Connect turns on proxying

func (*App) Disconnect

func (app *App) Disconnect()

Disconnect turns off proxying

func (*App) Exit

func (app *App) Exit(err error) bool

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

func (app *App) GetLanguage() string

GetLanguage returns the user language

func (*App) GetTranslations

func (app *App) GetTranslations(filename string) ([]byte, error)

GetTranslations accesses translations with the given filename

func (*App) IsPro

func (app *App) IsPro() bool

IsPro indicates whether or not the app is pro

func (*App) IsProUser

func (app *App) IsProUser() (isPro bool, ok bool)

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 *App) IsSysProxyOn() bool

func (*App) LogPanicAndExit

func (app *App) LogPanicAndExit(msg string)

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

func (app *App) OnStatsChange(fn func(stats.Stats))

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) PlansURL

func (app *App) PlansURL() string

PlansURL returns the URL for accessing the checkout/plans page directly.

func (*App) ProxyAddrReachable

func (app *App) ProxyAddrReachable(ctx context.Context) error

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) Run

func (app *App) Run(isMain bool)

Run starts the app.

func (*App) SelectedTab

func (app *App) SelectedTab() Tab

func (*App) SetLanguage

func (app *App) SetLanguage(lang string)

SetLanguage sets the user language

func (*App) SetReferralCode

func (app *App) SetReferralCode(referralCode string)

func (*App) SetSelectedTab

func (app *App) SetSelectedTab(selectedTab Tab)

func (*App) SetStats

func (app *App) SetStats(st *stats.Stats)

func (*App) SetSysProxy

func (app *App) SetSysProxy(_sysproxyOff func() error)

func (*App) Settings

func (app *App) Settings() *Settings

func (*App) Stats

func (app *App) Stats() *stats.Stats

func (*App) SysProxyOff

func (app *App) SysProxyOff() (err error)

func (*App) SysproxyOn

func (app *App) SysproxyOn() (err error)

func (*App) WaitForExit

func (app *App) WaitForExit() error

WaitForExit waits for a request to exit the application.

func (*App) WebsocketAddr

func (app *App) WebsocketAddr() string

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

type Settings struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Settings is a struct of all settings unique to this particular Lantern instance.

func LoadSettingsFrom

func LoadSettingsFrom(version, revisionDate, buildDate, path string) *Settings

func (*Settings) GetAddr

func (s *Settings) GetAddr() string

GetAddr gets the HTTP proxy address.

func (*Settings) GetAppName

func (s *Settings) GetAppName() string

func (*Settings) GetCountry

func (s *Settings) GetCountry() string

GetCountry returns the user country

func (*Settings) GetDeviceID

func (s *Settings) GetDeviceID() string

GetDeviceID returns the unique ID of this device.

func (*Settings) GetEmailAddress

func (s *Settings) GetEmailAddress() string

GetEmailAddress gets the email address of pro users.

func (*Settings) GetEnabledExperiments

func (s *Settings) GetEnabledExperiments() []string

GetEnabledExperiments returns the names of the Lantern experiment IDs that were enabled via flags.

func (*Settings) GetGoogleAds

func (s *Settings) GetGoogleAds() bool

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

func (s *Settings) GetInternalHeaders() map[string]string

GetInternalHeaders returns extra headers sent with requests to internal services

func (*Settings) GetLanguage

func (s *Settings) GetLanguage() string

GetLanguage returns the user language

func (*Settings) GetLocalHTTPToken

func (s *Settings) GetLocalHTTPToken() string

GetLocalHTTPToken returns the local HTTP token.

func (*Settings) GetMigratedDeviceIDForUserID

func (s *Settings) GetMigratedDeviceIDForUserID() int64

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

func (s *Settings) GetProxyAll() bool

GetProxyAll returns whether or not to proxy all traffic.

func (*Settings) GetSystemProxy

func (s *Settings) GetSystemProxy() bool

GetSystemProxy returns whether or not to set system proxy when lantern starts

func (*Settings) GetTakenSurveys

func (s *Settings) GetTakenSurveys() []string

GetTakenSurveys returns the IDs of surveys the user has already taken.

func (*Settings) GetTimeZone

func (s *Settings) GetTimeZone() (string, error)

func (*Settings) GetToken

func (s *Settings) GetToken() string

GetToken returns the user token

func (*Settings) GetUIAddr

func (s *Settings) GetUIAddr() string

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) GetUserID

func (s *Settings) GetUserID() int64

GetUserID returns the user ID

func (*Settings) IsAutoLaunch

func (s *Settings) IsAutoLaunch() bool

IsAutoLaunch returns whether or not to automatically launch on system startup.

func (*Settings) IsAutoReport

func (s *Settings) IsAutoReport() bool

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

func (s *Settings) SetCountry(country string)

SetCountry sets the user's country.

func (*Settings) SetEmailAddress

func (s *Settings) SetEmailAddress(email string)

SetEmailAddress locally stores the email address of a pro user

func (*Settings) SetEnabledExperiments

func (s *Settings) SetEnabledExperiments(ex []string)

SetEnabledExperiments sets the Lantern experiment IDs that were enabled via flags.

func (*Settings) SetGoogleAds

func (s *Settings) SetGoogleAds(g bool)

SetGoogleAds sets whether or not to proxy all traffic.

func (*Settings) SetLanguage

func (s *Settings) SetLanguage(language string)

SetLanguage sets the user language

func (*Settings) SetLocalHTTPToken

func (s *Settings) SetLocalHTTPToken(token string)

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

func (s *Settings) SetMigratedDeviceIDForUserID(userID int64)

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

func (s *Settings) SetProxyAll(proxyAll bool)

SetProxyAll sets whether or not to proxy all traffic.

func (*Settings) SetTakenSurveys

func (s *Settings) SetTakenSurveys(campaigns []string)

SetTakenSurveys sets the IDs of taken surveys.

func (*Settings) SetUIAddr

func (s *Settings) SetUIAddr(uiaddr string)

SetUIAddr sets the last known UI address.

func (*Settings) SetUserIDAndToken

func (s *Settings) SetUserIDAndToken(id int64, token string)

SetUserIDAndToken sets the user ID and token atomically

func (*Settings) StartService

func (s *Settings) StartService(channel ws.UIChannel) error

StartService starts the settings service that synchronizes Lantern's configuration with every UI client

type Tab

type Tab string

Identifies a specific tab in the desktop app

func ParseTab

func ParseTab(s string) (Tab, error)

Parse the given string into a Tab

Jump to

Keyboard shortcuts

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